diff --git a/doc/GeneratorMigration/Library_Inventory.md b/doc/GeneratorMigration/Library_Inventory.md index 444da3189227..baeeec0adc5d 100644 --- a/doc/GeneratorMigration/Library_Inventory.md +++ b/doc/GeneratorMigration/Library_Inventory.md @@ -3,15 +3,15 @@ ## Summary - Total libraries: 421 -- Management Plane (Swagger): 162 -- Management Plane (TSP-Old): 42 +- Management Plane (Swagger): 161 +- Management Plane (TSP-Old): 41 - Management Plane (TypeSpec - @azure-typespec/http-client-csharp): 0 -- Management Plane (TypeSpec - @azure-typespec/http-client-csharp-mgmt): 21 +- Management Plane (TypeSpec - @azure-typespec/http-client-csharp-mgmt): 23 - Management Plane (TypeSpec - @typespec/http-client-csharp): 0 - Management Plane (TypeSpec - Unknown TypeSpec Generator: eng/emitter-package.json): 0 - Data Plane (Swagger): 111 -- Data Plane (TSP-Old): 17 -- Data Plane (TypeSpec - @azure-typespec/http-client-csharp): 13 +- Data Plane (TSP-Old): 16 +- Data Plane (TypeSpec - @azure-typespec/http-client-csharp): 14 - Data Plane (TypeSpec - @azure-typespec/http-client-csharp-mgmt): 0 - Data Plane (TypeSpec - @typespec/http-client-csharp): 2 - Data Plane (TypeSpec - Unknown TypeSpec Generator: eng/emitter-package.json): 1 @@ -20,7 +20,7 @@ ## Data Plane Libraries using TypeSpec (@azure-typespec/http-client-csharp) -TypeSpec with @azure-typespec/http-client-csharp generator is detected by the presence of a tsp-location.yaml file with an emitterPackageJsonPath value referencing @azure-typespec/http-client-csharp, or through special handling for specific libraries. Total: 13 +TypeSpec with @azure-typespec/http-client-csharp generator is detected by the presence of a tsp-location.yaml file with an emitterPackageJsonPath value referencing @azure-typespec/http-client-csharp, or through special handling for specific libraries. Total: 14 | Service | Library | Path | | ------- | ------- | ---- | @@ -36,6 +36,7 @@ TypeSpec with @azure-typespec/http-client-csharp generator is detected by the pr | monitor | Azure.Monitor.Query.Logs | sdk/monitor/Azure.Monitor.Query.Logs | | monitor | Azure.Monitor.Query.Metrics | sdk/monitor/Azure.Monitor.Query.Metrics | | schemaregistry | Azure.Data.SchemaRegistry | sdk/schemaregistry/Azure.Data.SchemaRegistry | +| translation | Azure.AI.Translation.Text | sdk/translation/Azure.AI.Translation.Text | | vision | Azure.AI.Vision.ImageAnalysis | sdk/vision/Azure.AI.Vision.ImageAnalysis | @@ -60,7 +61,7 @@ TypeSpec with Unknown TypeSpec Generator: eng/emitter-package.json generator is ## Data Plane Libraries using TypeSpec (Old Generator) -TypeSpec with old generator is detected by the presence of a tsp-location.yaml file without an emitterPackageJsonPath value, tspconfig.yaml file, tsp directory, or *.tsp files. Total: 17 +TypeSpec with old generator is detected by the presence of a tsp-location.yaml file without an emitterPackageJsonPath value, tspconfig.yaml file, tsp directory, or *.tsp files. Total: 16 | Service | Library | Path | | ------- | ------- | ---- | @@ -80,7 +81,6 @@ TypeSpec with old generator is detected by the presence of a tsp-location.yaml f | onlineexperimentation | Azure.Analytics.OnlineExperimentation | sdk/onlineexperimentation/Azure.Analytics.OnlineExperimentation | | purview | Azure.Analytics.Purview.DataMap | sdk/purview/Azure.Analytics.Purview.DataMap | | translation | Azure.AI.Translation.Document | sdk/translation/Azure.AI.Translation.Document | -| translation | Azure.AI.Translation.Text | sdk/translation/Azure.AI.Translation.Text | ## Data Plane Libraries using Swagger @@ -204,7 +204,7 @@ Total: 111 ## Management Plane Libraries using TypeSpec (@azure-typespec/http-client-csharp-mgmt) -TypeSpec with @azure-typespec/http-client-csharp-mgmt generator is detected by the presence of a tsp-location.yaml file with an emitterPackageJsonPath value referencing @azure-typespec/http-client-csharp-mgmt, or through special handling for specific libraries. Total: 21 +TypeSpec with @azure-typespec/http-client-csharp-mgmt generator is detected by the presence of a tsp-location.yaml file with an emitterPackageJsonPath value referencing @azure-typespec/http-client-csharp-mgmt, or through special handling for specific libraries. Total: 23 | Service | Library | Path | | ------- | ------- | ---- | @@ -213,6 +213,7 @@ TypeSpec with @azure-typespec/http-client-csharp-mgmt generator is detected by t | cloudhealth | Azure.ResourceManager.CloudHealth | sdk/cloudhealth/Azure.ResourceManager.CloudHealth | | computerecommender | Azure.ResourceManager.Compute.Recommender | sdk/computerecommender/Azure.ResourceManager.Compute.Recommender | | connectedcache | Azure.ResourceManager.ConnectedCache | sdk/connectedcache/Azure.ResourceManager.ConnectedCache | +| databasewatcher | Azure.ResourceManager.DatabaseWatcher | sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher | | dellstorage | Azure.ResourceManager.Dell.Storage | sdk/dellstorage/Azure.ResourceManager.Dell.Storage | | dependencymap | Azure.ResourceManager.DependencyMap | sdk/dependencymap/Azure.ResourceManager.DependencyMap | | deviceregistry | Azure.ResourceManager.DeviceRegistry | sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry | @@ -221,6 +222,7 @@ TypeSpec with @azure-typespec/http-client-csharp-mgmt generator is detected by t | hybridkubernetes | Azure.ResourceManager.Kubernetes | sdk/hybridkubernetes/Azure.ResourceManager.Kubernetes | | informaticadatamanagement | Azure.ResourceManager.InformaticaDataManagement | sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement | | lambdatesthyperexecute | Azure.ResourceManager.LambdaTestHyperExecute | sdk/lambdatesthyperexecute/Azure.ResourceManager.LambdaTestHyperExecute | +| paloaltonetworks.ngfw | Azure.ResourceManager.PaloAltoNetworks.Ngfw | sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw | | pineconevectordb | Azure.ResourceManager.PineconeVectorDB | sdk/pineconevectordb/Azure.ResourceManager.PineconeVectorDB | | planetarycomputer | Azure.ResourceManager.PlanetaryComputer | sdk/planetarycomputer/Azure.ResourceManager.PlanetaryComputer | | playwright | Azure.ResourceManager.Playwright | sdk/playwright/Azure.ResourceManager.Playwright | @@ -233,7 +235,7 @@ TypeSpec with @azure-typespec/http-client-csharp-mgmt generator is detected by t ## Management Plane Libraries using TypeSpec (Old Generator) -TypeSpec with old generator is detected by the presence of a tsp-location.yaml file without an emitterPackageJsonPath value, tspconfig.yaml file, tsp directory, or *.tsp files. Total: 42 +TypeSpec with old generator is detected by the presence of a tsp-location.yaml file without an emitterPackageJsonPath value, tspconfig.yaml file, tsp directory, or *.tsp files. Total: 41 | Service | Library | Path | | ------- | ------- | ---- | @@ -244,7 +246,6 @@ TypeSpec with old generator is detected by the presence of a tsp-location.yaml f | computefleet | Azure.ResourceManager.ComputeFleet | sdk/computefleet/Azure.ResourceManager.ComputeFleet | | computeschedule | Azure.ResourceManager.ComputeSchedule | sdk/computeschedule/Azure.ResourceManager.ComputeSchedule | | containerorchestratorruntime | Azure.ResourceManager.ContainerOrchestratorRuntime | sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime | -| databasewatcher | Azure.ResourceManager.DatabaseWatcher | sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher | | databox | Azure.ResourceManager.DataBox | sdk/databox/Azure.ResourceManager.DataBox | | deviceprovisioningservices | Azure.ResourceManager.DeviceProvisioningServices | sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices | | devopsinfrastructure | Azure.ResourceManager.DevOpsInfrastructure | sdk/devopsinfrastructure/Azure.ResourceManager.DevOpsInfrastructure | @@ -283,7 +284,7 @@ TypeSpec with old generator is detected by the presence of a tsp-location.yaml f ## Management Plane Libraries using Swagger -Total: 162 +Total: 161 | Service | Library | Path | | ------- | ------- | ---- | @@ -400,7 +401,6 @@ Total: 162 | openenergyplatform | Azure.ResourceManager.EnergyServices | sdk/openenergyplatform/Azure.ResourceManager.EnergyServices | | operationalinsights | Azure.ResourceManager.OperationalInsights | sdk/operationalinsights/Azure.ResourceManager.OperationalInsights | | orbital | Azure.ResourceManager.Orbital | sdk/orbital/Azure.ResourceManager.Orbital | -| paloaltonetworks.ngfw | Azure.ResourceManager.PaloAltoNetworks.Ngfw | sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw | | peering | Azure.ResourceManager.Peering | sdk/peering/Azure.ResourceManager.Peering | | policyinsights | Azure.ResourceManager.PolicyInsights | sdk/policyinsights/Azure.ResourceManager.PolicyInsights | | postgresql | Azure.ResourceManager.PostgreSql | sdk/postgresql/Azure.ResourceManager.PostgreSql | diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/api/Azure.ResourceManager.DatabaseWatcher.net8.0.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/api/Azure.ResourceManager.DatabaseWatcher.net8.0.cs index ed3f30f3b56d..73699b47e190 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/api/Azure.ResourceManager.DatabaseWatcher.net8.0.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/api/Azure.ResourceManager.DatabaseWatcher.net8.0.cs @@ -27,7 +27,10 @@ public partial class DatabaseWatcherAlertRuleData : Azure.ResourceManager.Models { public DatabaseWatcherAlertRuleData() { } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherAlertRuleProperties Properties { 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.DatabaseWatcher.DatabaseWatcherAlertRuleData 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.DatabaseWatcher.DatabaseWatcherAlertRuleData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -75,7 +78,10 @@ public partial class DatabaseWatcherData : Azure.ResourceManager.Models.TrackedR public DatabaseWatcherData(Azure.Core.AzureLocation location) { } public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProperties Properties { 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.DatabaseWatcher.DatabaseWatcherData 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.DatabaseWatcher.DatabaseWatcherData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -114,7 +120,10 @@ public partial class DatabaseWatcherHealthValidationData : Azure.ResourceManager { internal DatabaseWatcherHealthValidationData() { } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationProperties Properties { get { throw null; } } + 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.DatabaseWatcher.DatabaseWatcherHealthValidationData 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.DatabaseWatcher.DatabaseWatcherHealthValidationData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -219,7 +228,10 @@ public partial class DatabaseWatcherSharedPrivateLinkResourceData : Azure.Resour { public DatabaseWatcherSharedPrivateLinkResourceData() { } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceProperties Properties { 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.DatabaseWatcher.DatabaseWatcherSharedPrivateLinkResourceData 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.DatabaseWatcher.DatabaseWatcherSharedPrivateLinkResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -247,7 +259,10 @@ public partial class DatabaseWatcherTargetData : Azure.ResourceManager.Models.Re { public DatabaseWatcherTargetData() { } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties Properties { 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.DatabaseWatcher.DatabaseWatcherTargetData 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.DatabaseWatcher.DatabaseWatcherTargetData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -316,6 +331,7 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty left, Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty left, Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty right) { throw null; } public override string ToString() { throw null; } } @@ -327,6 +343,7 @@ public static partial class ArmDatabaseWatcherModelFactory public static Azure.ResourceManager.DatabaseWatcher.DatabaseWatcherHealthValidationData DatabaseWatcherHealthValidationData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationProperties properties = null) { throw null; } public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationIssue DatabaseWatcherHealthValidationIssue(string errorCode = null, string errorMessage = null, string additionalDetails = null, string recommendationMessage = null, System.Uri recommendationUri = null, Azure.Core.ResourceIdentifier relatedResourceId = null, Azure.Core.ResourceType? relatedResourceType = default(Azure.Core.ResourceType?)) { throw null; } public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationProperties DatabaseWatcherHealthValidationProperties(System.DateTimeOffset startOn = default(System.DateTimeOffset), System.DateTimeOffset endOn = default(System.DateTimeOffset), Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus status = default(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus), System.Collections.Generic.IEnumerable issues = null, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState?)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherPatch DatabaseWatcherPatch(Azure.ResourceManager.Models.ManagedServiceIdentity identity = null, System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherUpdateProperties properties = null) { throw null; } public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProperties DatabaseWatcherProperties(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherDatastore datastore = null, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus? status = default(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus?), Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState?), Azure.Core.ResourceIdentifier defaultAlertRuleIdentityResourceId = null) { throw null; } public static Azure.ResourceManager.DatabaseWatcher.DatabaseWatcherSharedPrivateLinkResourceData DatabaseWatcherSharedPrivateLinkResourceData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceProperties properties = null) { throw null; } public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceProperties DatabaseWatcherSharedPrivateLinkResourceProperties(Azure.Core.ResourceIdentifier privateLinkResourceId = null, string groupId = null, string requestMessage = null, string dnsZone = null, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus? status = default(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus?), Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState?)) { throw null; } @@ -345,7 +362,10 @@ public DatabaseWatcherAlertRuleProperties(Azure.Core.ResourceIdentifier alertRul public System.DateTimeOffset CreatedOn { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty CreatedWithProperties { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState? ProvisioningState { get { throw null; } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherAlertRuleProperties 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.DatabaseWatcher.Models.DatabaseWatcherAlertRuleProperties 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.DatabaseWatcher.Models.DatabaseWatcherAlertRuleProperties 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.DatabaseWatcher.Models.DatabaseWatcherAlertRuleProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -362,7 +382,10 @@ public DatabaseWatcherDatastore(System.Uri kustoClusterUri, System.Uri kustoData public System.Uri KustoDataIngestionUri { get { throw null; } set { } } public System.Uri KustoManagementUri { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType KustoOfferingType { get { throw null; } set { } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherDatastore 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.DatabaseWatcher.Models.DatabaseWatcherDatastore 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.DatabaseWatcher.Models.DatabaseWatcherDatastore 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.DatabaseWatcher.Models.DatabaseWatcherDatastore System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -379,7 +402,10 @@ internal DatabaseWatcherHealthValidationIssue() { } public System.Uri RecommendationUri { get { throw null; } } public Azure.Core.ResourceIdentifier RelatedResourceId { get { throw null; } } public Azure.Core.ResourceType? RelatedResourceType { get { throw null; } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationIssue 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.DatabaseWatcher.Models.DatabaseWatcherHealthValidationIssue 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.DatabaseWatcher.Models.DatabaseWatcherHealthValidationIssue 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.DatabaseWatcher.Models.DatabaseWatcherHealthValidationIssue System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -394,7 +420,10 @@ internal DatabaseWatcherHealthValidationProperties() { } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState? ProvisioningState { get { throw null; } } public System.DateTimeOffset StartOn { get { throw null; } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus Status { get { throw null; } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationProperties 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.DatabaseWatcher.Models.DatabaseWatcherHealthValidationProperties 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.DatabaseWatcher.Models.DatabaseWatcherHealthValidationProperties 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.DatabaseWatcher.Models.DatabaseWatcherHealthValidationProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -420,6 +449,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus right) { throw null; } public override string ToString() { throw null; } } @@ -429,7 +459,10 @@ public DatabaseWatcherPatch() { } public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherUpdateProperties Properties { get { throw null; } set { } } public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherPatch 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.DatabaseWatcher.Models.DatabaseWatcherPatch 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.DatabaseWatcher.Models.DatabaseWatcherPatch 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.DatabaseWatcher.Models.DatabaseWatcherPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -443,7 +476,10 @@ public DatabaseWatcherProperties() { } public Azure.Core.ResourceIdentifier DefaultAlertRuleIdentityResourceId { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState? ProvisioningState { get { throw null; } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus? Status { get { throw null; } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProperties 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.DatabaseWatcher.Models.DatabaseWatcherProperties 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.DatabaseWatcher.Models.DatabaseWatcherProperties 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.DatabaseWatcher.Models.DatabaseWatcherProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -466,6 +502,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState right) { throw null; } public override string ToString() { throw null; } } @@ -485,6 +522,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState right) { throw null; } public override string ToString() { throw null; } } @@ -497,7 +535,10 @@ public DatabaseWatcherSharedPrivateLinkResourceProperties(Azure.Core.ResourceIde public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState? ProvisioningState { get { throw null; } } public string RequestMessage { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus? Status { get { throw null; } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceProperties 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.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceProperties 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.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceProperties 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.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -521,6 +562,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus right) { throw null; } public override string ToString() { throw null; } } @@ -542,17 +584,21 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus right) { throw null; } public override string ToString() { throw null; } } public abstract partial class DatabaseWatcherTargetProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - protected DatabaseWatcherTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName) { } + internal DatabaseWatcherTargetProperties() { } public string ConnectionServerName { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState? ProvisioningState { get { throw null; } } public Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType TargetAuthenticationType { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationVaultSecret TargetVault { get { throw null; } set { } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties 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.DatabaseWatcher.Models.DatabaseWatcherTargetProperties 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.DatabaseWatcher.Models.DatabaseWatcherTargetProperties 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.DatabaseWatcher.Models.DatabaseWatcherTargetProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -564,7 +610,10 @@ public partial class DatabaseWatcherUpdateProperties : System.ClientModel.Primit public DatabaseWatcherUpdateProperties() { } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherDatastore Datastore { get { throw null; } set { } } public Azure.Core.ResourceIdentifier DefaultAlertRuleIdentityResourceId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherUpdateProperties 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.DatabaseWatcher.Models.DatabaseWatcherUpdateProperties 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.DatabaseWatcher.Models.DatabaseWatcherUpdateProperties 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.DatabaseWatcher.Models.DatabaseWatcherUpdateProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -587,16 +636,20 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType left, Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType left, Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType right) { throw null; } public override string ToString() { throw null; } } public partial class SqlDBElasticPoolTargetProperties : Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public SqlDBElasticPoolTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName, Azure.Core.ResourceIdentifier sqlEpResourceId, Azure.Core.ResourceIdentifier anchorDatabaseResourceId) : base (default(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType), default(string)) { } + public SqlDBElasticPoolTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName, Azure.Core.ResourceIdentifier sqlEpResourceId, Azure.Core.ResourceIdentifier anchorDatabaseResourceId) { } public Azure.Core.ResourceIdentifier AnchorDatabaseResourceId { get { throw null; } set { } } public bool? ReadIntent { get { throw null; } set { } } public Azure.Core.ResourceIdentifier SqlEpResourceId { get { throw null; } set { } } + protected override Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties 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 override Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.DatabaseWatcher.Models.SqlDBElasticPoolTargetProperties 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.DatabaseWatcher.Models.SqlDBElasticPoolTargetProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -605,10 +658,13 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write } public partial class SqlDBSingleDatabaseTargetProperties : Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public SqlDBSingleDatabaseTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName, Azure.Core.ResourceIdentifier sqlDbResourceId) : base (default(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType), default(string)) { } + public SqlDBSingleDatabaseTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName, Azure.Core.ResourceIdentifier sqlDbResourceId) { } public bool? ReadIntent { get { throw null; } set { } } public Azure.Core.ResourceIdentifier SqlDbResourceId { get { throw null; } set { } } + protected override Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties 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 override Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.DatabaseWatcher.Models.SqlDBSingleDatabaseTargetProperties 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.DatabaseWatcher.Models.SqlDBSingleDatabaseTargetProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -617,11 +673,14 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write } public partial class SqlMITargetProperties : Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public SqlMITargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName, Azure.Core.ResourceIdentifier sqlMiResourceId) : base (default(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType), default(string)) { } + public SqlMITargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName, Azure.Core.ResourceIdentifier sqlMiResourceId) { } public int? ConnectionTcpPort { get { throw null; } set { } } public bool? ReadIntent { get { throw null; } set { } } public Azure.Core.ResourceIdentifier SqlMiResourceId { get { throw null; } set { } } + protected override Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties 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 override Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.DatabaseWatcher.Models.SqlMITargetProperties 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.DatabaseWatcher.Models.SqlMITargetProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -643,6 +702,7 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType left, Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType left, Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType right) { throw null; } public override string ToString() { throw null; } } @@ -652,7 +712,10 @@ public TargetAuthenticationVaultSecret() { } public Azure.Core.ResourceIdentifier AkvResourceId { get { throw null; } set { } } public string AkvTargetPassword { get { throw null; } set { } } public string AkvTargetUser { get { throw null; } set { } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationVaultSecret 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.DatabaseWatcher.Models.TargetAuthenticationVaultSecret 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.DatabaseWatcher.Models.TargetAuthenticationVaultSecret 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.DatabaseWatcher.Models.TargetAuthenticationVaultSecret System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/api/Azure.ResourceManager.DatabaseWatcher.netstandard2.0.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/api/Azure.ResourceManager.DatabaseWatcher.netstandard2.0.cs index ed3f30f3b56d..73699b47e190 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/api/Azure.ResourceManager.DatabaseWatcher.netstandard2.0.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/api/Azure.ResourceManager.DatabaseWatcher.netstandard2.0.cs @@ -27,7 +27,10 @@ public partial class DatabaseWatcherAlertRuleData : Azure.ResourceManager.Models { public DatabaseWatcherAlertRuleData() { } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherAlertRuleProperties Properties { 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.DatabaseWatcher.DatabaseWatcherAlertRuleData 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.DatabaseWatcher.DatabaseWatcherAlertRuleData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -75,7 +78,10 @@ public partial class DatabaseWatcherData : Azure.ResourceManager.Models.TrackedR public DatabaseWatcherData(Azure.Core.AzureLocation location) { } public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProperties Properties { 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.DatabaseWatcher.DatabaseWatcherData 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.DatabaseWatcher.DatabaseWatcherData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -114,7 +120,10 @@ public partial class DatabaseWatcherHealthValidationData : Azure.ResourceManager { internal DatabaseWatcherHealthValidationData() { } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationProperties Properties { get { throw null; } } + 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.DatabaseWatcher.DatabaseWatcherHealthValidationData 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.DatabaseWatcher.DatabaseWatcherHealthValidationData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -219,7 +228,10 @@ public partial class DatabaseWatcherSharedPrivateLinkResourceData : Azure.Resour { public DatabaseWatcherSharedPrivateLinkResourceData() { } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceProperties Properties { 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.DatabaseWatcher.DatabaseWatcherSharedPrivateLinkResourceData 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.DatabaseWatcher.DatabaseWatcherSharedPrivateLinkResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -247,7 +259,10 @@ public partial class DatabaseWatcherTargetData : Azure.ResourceManager.Models.Re { public DatabaseWatcherTargetData() { } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties Properties { 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.DatabaseWatcher.DatabaseWatcherTargetData 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.DatabaseWatcher.DatabaseWatcherTargetData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -316,6 +331,7 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty left, Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty left, Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty right) { throw null; } public override string ToString() { throw null; } } @@ -327,6 +343,7 @@ public static partial class ArmDatabaseWatcherModelFactory public static Azure.ResourceManager.DatabaseWatcher.DatabaseWatcherHealthValidationData DatabaseWatcherHealthValidationData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationProperties properties = null) { throw null; } public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationIssue DatabaseWatcherHealthValidationIssue(string errorCode = null, string errorMessage = null, string additionalDetails = null, string recommendationMessage = null, System.Uri recommendationUri = null, Azure.Core.ResourceIdentifier relatedResourceId = null, Azure.Core.ResourceType? relatedResourceType = default(Azure.Core.ResourceType?)) { throw null; } public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationProperties DatabaseWatcherHealthValidationProperties(System.DateTimeOffset startOn = default(System.DateTimeOffset), System.DateTimeOffset endOn = default(System.DateTimeOffset), Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus status = default(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus), System.Collections.Generic.IEnumerable issues = null, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState?)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherPatch DatabaseWatcherPatch(Azure.ResourceManager.Models.ManagedServiceIdentity identity = null, System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherUpdateProperties properties = null) { throw null; } public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProperties DatabaseWatcherProperties(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherDatastore datastore = null, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus? status = default(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus?), Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState?), Azure.Core.ResourceIdentifier defaultAlertRuleIdentityResourceId = null) { throw null; } public static Azure.ResourceManager.DatabaseWatcher.DatabaseWatcherSharedPrivateLinkResourceData DatabaseWatcherSharedPrivateLinkResourceData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceProperties properties = null) { throw null; } public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceProperties DatabaseWatcherSharedPrivateLinkResourceProperties(Azure.Core.ResourceIdentifier privateLinkResourceId = null, string groupId = null, string requestMessage = null, string dnsZone = null, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus? status = default(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus?), Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState?)) { throw null; } @@ -345,7 +362,10 @@ public DatabaseWatcherAlertRuleProperties(Azure.Core.ResourceIdentifier alertRul public System.DateTimeOffset CreatedOn { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty CreatedWithProperties { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState? ProvisioningState { get { throw null; } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherAlertRuleProperties 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.DatabaseWatcher.Models.DatabaseWatcherAlertRuleProperties 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.DatabaseWatcher.Models.DatabaseWatcherAlertRuleProperties 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.DatabaseWatcher.Models.DatabaseWatcherAlertRuleProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -362,7 +382,10 @@ public DatabaseWatcherDatastore(System.Uri kustoClusterUri, System.Uri kustoData public System.Uri KustoDataIngestionUri { get { throw null; } set { } } public System.Uri KustoManagementUri { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType KustoOfferingType { get { throw null; } set { } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherDatastore 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.DatabaseWatcher.Models.DatabaseWatcherDatastore 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.DatabaseWatcher.Models.DatabaseWatcherDatastore 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.DatabaseWatcher.Models.DatabaseWatcherDatastore System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -379,7 +402,10 @@ internal DatabaseWatcherHealthValidationIssue() { } public System.Uri RecommendationUri { get { throw null; } } public Azure.Core.ResourceIdentifier RelatedResourceId { get { throw null; } } public Azure.Core.ResourceType? RelatedResourceType { get { throw null; } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationIssue 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.DatabaseWatcher.Models.DatabaseWatcherHealthValidationIssue 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.DatabaseWatcher.Models.DatabaseWatcherHealthValidationIssue 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.DatabaseWatcher.Models.DatabaseWatcherHealthValidationIssue System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -394,7 +420,10 @@ internal DatabaseWatcherHealthValidationProperties() { } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState? ProvisioningState { get { throw null; } } public System.DateTimeOffset StartOn { get { throw null; } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus Status { get { throw null; } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationProperties 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.DatabaseWatcher.Models.DatabaseWatcherHealthValidationProperties 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.DatabaseWatcher.Models.DatabaseWatcherHealthValidationProperties 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.DatabaseWatcher.Models.DatabaseWatcherHealthValidationProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -420,6 +449,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherHealthValidationStatus right) { throw null; } public override string ToString() { throw null; } } @@ -429,7 +459,10 @@ public DatabaseWatcherPatch() { } public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherUpdateProperties Properties { get { throw null; } set { } } public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherPatch 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.DatabaseWatcher.Models.DatabaseWatcherPatch 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.DatabaseWatcher.Models.DatabaseWatcherPatch 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.DatabaseWatcher.Models.DatabaseWatcherPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -443,7 +476,10 @@ public DatabaseWatcherProperties() { } public Azure.Core.ResourceIdentifier DefaultAlertRuleIdentityResourceId { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState? ProvisioningState { get { throw null; } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus? Status { get { throw null; } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProperties 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.DatabaseWatcher.Models.DatabaseWatcherProperties 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.DatabaseWatcher.Models.DatabaseWatcherProperties 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.DatabaseWatcher.Models.DatabaseWatcherProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -466,6 +502,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState right) { throw null; } public override string ToString() { throw null; } } @@ -485,6 +522,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState right) { throw null; } public override string ToString() { throw null; } } @@ -497,7 +535,10 @@ public DatabaseWatcherSharedPrivateLinkResourceProperties(Azure.Core.ResourceIde public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState? ProvisioningState { get { throw null; } } public string RequestMessage { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus? Status { get { throw null; } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceProperties 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.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceProperties 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.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceProperties 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.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -521,6 +562,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherSharedPrivateLinkResourceStatus right) { throw null; } public override string ToString() { throw null; } } @@ -542,17 +584,21 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherStatus right) { throw null; } public override string ToString() { throw null; } } public abstract partial class DatabaseWatcherTargetProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - protected DatabaseWatcherTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName) { } + internal DatabaseWatcherTargetProperties() { } public string ConnectionServerName { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherResourceProvisioningState? ProvisioningState { get { throw null; } } public Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType TargetAuthenticationType { get { throw null; } set { } } public Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationVaultSecret TargetVault { get { throw null; } set { } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties 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.DatabaseWatcher.Models.DatabaseWatcherTargetProperties 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.DatabaseWatcher.Models.DatabaseWatcherTargetProperties 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.DatabaseWatcher.Models.DatabaseWatcherTargetProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -564,7 +610,10 @@ public partial class DatabaseWatcherUpdateProperties : System.ClientModel.Primit public DatabaseWatcherUpdateProperties() { } public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherDatastore Datastore { get { throw null; } set { } } public Azure.Core.ResourceIdentifier DefaultAlertRuleIdentityResourceId { get { throw null; } set { } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherUpdateProperties 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.DatabaseWatcher.Models.DatabaseWatcherUpdateProperties 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.DatabaseWatcher.Models.DatabaseWatcherUpdateProperties 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.DatabaseWatcher.Models.DatabaseWatcherUpdateProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -587,16 +636,20 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType left, Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType left, Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType right) { throw null; } public override string ToString() { throw null; } } public partial class SqlDBElasticPoolTargetProperties : Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public SqlDBElasticPoolTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName, Azure.Core.ResourceIdentifier sqlEpResourceId, Azure.Core.ResourceIdentifier anchorDatabaseResourceId) : base (default(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType), default(string)) { } + public SqlDBElasticPoolTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName, Azure.Core.ResourceIdentifier sqlEpResourceId, Azure.Core.ResourceIdentifier anchorDatabaseResourceId) { } public Azure.Core.ResourceIdentifier AnchorDatabaseResourceId { get { throw null; } set { } } public bool? ReadIntent { get { throw null; } set { } } public Azure.Core.ResourceIdentifier SqlEpResourceId { get { throw null; } set { } } + protected override Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties 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 override Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.DatabaseWatcher.Models.SqlDBElasticPoolTargetProperties 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.DatabaseWatcher.Models.SqlDBElasticPoolTargetProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -605,10 +658,13 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write } public partial class SqlDBSingleDatabaseTargetProperties : Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public SqlDBSingleDatabaseTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName, Azure.Core.ResourceIdentifier sqlDbResourceId) : base (default(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType), default(string)) { } + public SqlDBSingleDatabaseTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName, Azure.Core.ResourceIdentifier sqlDbResourceId) { } public bool? ReadIntent { get { throw null; } set { } } public Azure.Core.ResourceIdentifier SqlDbResourceId { get { throw null; } set { } } + protected override Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties 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 override Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.DatabaseWatcher.Models.SqlDBSingleDatabaseTargetProperties 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.DatabaseWatcher.Models.SqlDBSingleDatabaseTargetProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -617,11 +673,14 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write } public partial class SqlMITargetProperties : Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public SqlMITargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName, Azure.Core.ResourceIdentifier sqlMiResourceId) : base (default(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType), default(string)) { } + public SqlMITargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName, Azure.Core.ResourceIdentifier sqlMiResourceId) { } public int? ConnectionTcpPort { get { throw null; } set { } } public bool? ReadIntent { get { throw null; } set { } } public Azure.Core.ResourceIdentifier SqlMiResourceId { get { throw null; } set { } } + protected override Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties 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 override Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherTargetProperties PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.DatabaseWatcher.Models.SqlMITargetProperties 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.DatabaseWatcher.Models.SqlMITargetProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -643,6 +702,7 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write public override int GetHashCode() { throw null; } public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType left, Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType right) { throw null; } public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType (string value) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType? (string value) { throw null; } public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType left, Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType right) { throw null; } public override string ToString() { throw null; } } @@ -652,7 +712,10 @@ public TargetAuthenticationVaultSecret() { } public Azure.Core.ResourceIdentifier AkvResourceId { get { throw null; } set { } } public string AkvTargetPassword { get { throw null; } set { } } public string AkvTargetUser { get { throw null; } set { } } + protected virtual Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationVaultSecret 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.DatabaseWatcher.Models.TargetAuthenticationVaultSecret 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.DatabaseWatcher.Models.TargetAuthenticationVaultSecret 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.DatabaseWatcher.Models.TargetAuthenticationVaultSecret System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Azure.ResourceManager.DatabaseWatcher.csproj b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Azure.ResourceManager.DatabaseWatcher.csproj index b75ee401b7a3..679711227bb2 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Azure.ResourceManager.DatabaseWatcher.csproj +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Azure.ResourceManager.DatabaseWatcher.csproj @@ -4,6 +4,5 @@ 1.0.0-beta.2 azure;management;arm;resource manager;databasewatcher Azure.ResourceManager.DatabaseWatcher - true diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Custom/DatabaseWatcherData.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Custom/DatabaseWatcherData.cs deleted file mode 100644 index 2fc8dcfe0725..000000000000 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Custom/DatabaseWatcherData.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#nullable disable - -using Azure.ResourceManager.Models; - -namespace Azure.ResourceManager.DatabaseWatcher -{ - /// - /// A class representing the DatabaseWatcher data model. - /// The DatabaseWatcherProviderHub resource. - /// - public partial class DatabaseWatcherData : TrackedResourceData - { - /// The managed service identities assigned to this resource. - public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get; set; } - } -} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Custom/Models/DatabaseWatcherPatch.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Custom/Models/DatabaseWatcherPatch.cs deleted file mode 100644 index a7abbe2f41cf..000000000000 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Custom/Models/DatabaseWatcherPatch.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#nullable disable - -using Azure.ResourceManager.Models; - -namespace Azure.ResourceManager.DatabaseWatcher.Models -{ - /// The type used for update operations of the Watcher. - public partial class DatabaseWatcherPatch - { - /// The managed service identities assigned to this resource. - public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get; set; } - } -} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Custom/Models/DatabaseWatcherUpdateProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Custom/Models/DatabaseWatcherUpdateProperties.cs index 58a44381bb24..52635b288bce 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Custom/Models/DatabaseWatcherUpdateProperties.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Custom/Models/DatabaseWatcherUpdateProperties.cs @@ -3,12 +3,10 @@ #nullable disable -using Azure.Core; - namespace Azure.ResourceManager.DatabaseWatcher.Models { /// The updatable properties of the Watcher. - [CodeGenModel("WatcherUpdateProperties")] + [CodeGenTypeAttribute("WatcherUpdateProperties")] public partial class DatabaseWatcherUpdateProperties { } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourcesGetByParentAsyncCollectionResultOfT.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourcesGetByParentAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..e064a920618d --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourcesGetByParentAsyncCollectionResultOfT.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class AlertRuleResourcesGetByParentAsyncCollectionResultOfT : AsyncPageable + { + private readonly AlertRuleResources _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _watcherName; + private readonly RequestContext _context; + + /// Initializes a new instance of AlertRuleResourcesGetByParentAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AlertRuleResources 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 database watcher name. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public AlertRuleResourcesGetByParentAsyncCollectionResultOfT(AlertRuleResources client, Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _watcherName = watcherName; + _context = context; + } + + /// Gets the pages of AlertRuleResourcesGetByParentAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AlertRuleResourcesGetByParentAsyncCollectionResultOfT 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; + } + AlertRuleResourceListResult result = AlertRuleResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)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.CreateNextGetByParentRequest(nextLink, _subscriptionId, _resourceGroupName, _watcherName, _context) : _client.CreateGetByParentRequest(_subscriptionId, _resourceGroupName, _watcherName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourcesGetByParentCollectionResultOfT.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourcesGetByParentCollectionResultOfT.cs new file mode 100644 index 000000000000..eecd5d67445d --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourcesGetByParentCollectionResultOfT.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class AlertRuleResourcesGetByParentCollectionResultOfT : Pageable + { + private readonly AlertRuleResources _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _watcherName; + private readonly RequestContext _context; + + /// Initializes a new instance of AlertRuleResourcesGetByParentCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The AlertRuleResources 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 database watcher name. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public AlertRuleResourcesGetByParentCollectionResultOfT(AlertRuleResources client, Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _watcherName = watcherName; + _context = context; + } + + /// Gets the pages of AlertRuleResourcesGetByParentCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of AlertRuleResourcesGetByParentCollectionResultOfT 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; + } + AlertRuleResourceListResult result = AlertRuleResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)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.CreateNextGetByParentRequest(nextLink, _subscriptionId, _resourceGroupName, _watcherName, _context) : _client.CreateGetByParentRequest(_subscriptionId, _resourceGroupName, _watcherName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/ArmDatabaseWatcherModelFactory.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/ArmDatabaseWatcherModelFactory.cs index 56a1aaa05757..ce33b7a2d277 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/ArmDatabaseWatcherModelFactory.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/ArmDatabaseWatcherModelFactory.cs @@ -8,70 +8,85 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DatabaseWatcher.Models { - /// Model factory for models. + /// A factory class for creating instances of the models for mocking. public static partial class ArmDatabaseWatcherModelFactory { - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. + + /// The DatabaseWatcherProviderHub resource. + /// 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. + /// Resource tags. + /// The geo-location where the resource lives. /// The resource-specific properties for this resource. /// The managed service identities assigned to this resource. /// A new instance for mocking. - public static DatabaseWatcherData DatabaseWatcherData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, DatabaseWatcherProperties properties = null, ManagedServiceIdentity identity = null) + public static DatabaseWatcherData DatabaseWatcherData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, DatabaseWatcherProperties properties = default, ManagedServiceIdentity identity = default) { - tags ??= new Dictionary(); + tags ??= new ChangeTrackingDictionary(); return new DatabaseWatcherData( id, name, resourceType, systemData, + additionalBinaryDataProperties: null, tags, location, properties, - identity, - serializedAdditionalRawData: null); + identity); } - /// Initializes a new instance of . + /// The RP specific properties of the resource. /// The data store for collected monitoring data. /// The monitoring collection status of the watcher. /// The provisioning state of the resource watcher. /// The resource ID of a user-assigned managed identity that will be assigned to a new alert rule. /// A new instance for mocking. - public static DatabaseWatcherProperties DatabaseWatcherProperties(DatabaseWatcherDatastore datastore = null, DatabaseWatcherStatus? status = null, DatabaseWatcherProvisioningState? provisioningState = null, ResourceIdentifier defaultAlertRuleIdentityResourceId = null) + public static DatabaseWatcherProperties DatabaseWatcherProperties(DatabaseWatcherDatastore datastore = default, DatabaseWatcherStatus? status = default, DatabaseWatcherProvisioningState? provisioningState = default, ResourceIdentifier defaultAlertRuleIdentityResourceId = default) + { + return new DatabaseWatcherProperties(datastore, status, provisioningState, defaultAlertRuleIdentityResourceId, additionalBinaryDataProperties: null); + } + + /// The type used for update operations of the Watcher. + /// The managed service identities assigned to this resource. + /// Resource tags. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static DatabaseWatcherPatch DatabaseWatcherPatch(ManagedServiceIdentity identity = default, IDictionary tags = default, DatabaseWatcherUpdateProperties properties = default) { - return new DatabaseWatcherProperties(datastore, status, provisioningState, defaultAlertRuleIdentityResourceId, serializedAdditionalRawData: null); + tags ??= new ChangeTrackingDictionary(); + + return new DatabaseWatcherPatch(identity, tags, properties, additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + /// 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. /// The resource-specific properties for this resource. /// A new instance for mocking. - public static DatabaseWatcherAlertRuleData DatabaseWatcherAlertRuleData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, DatabaseWatcherAlertRuleProperties properties = null) + public static DatabaseWatcherAlertRuleData DatabaseWatcherAlertRuleData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, DatabaseWatcherAlertRuleProperties properties = default) { return new DatabaseWatcherAlertRuleData( id, name, resourceType, systemData, - properties, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null, + properties); } - /// Initializes a new instance of . + /// The generic properties of the alert rule proxy resource. /// The resource ID of the alert rule resource. /// The properties with which the alert rule resource was created. /// The creation time of the alert rule resource. @@ -79,7 +94,7 @@ public static DatabaseWatcherAlertRuleData DatabaseWatcherAlertRuleData(Resource /// The template ID associated with alert rule resource. /// The alert rule template version. /// A new instance for mocking. - public static DatabaseWatcherAlertRuleProperties DatabaseWatcherAlertRuleProperties(ResourceIdentifier alertRuleResourceId = null, AlertRuleCreationProperty createdWithProperties = default, DateTimeOffset createdOn = default, DatabaseWatcherResourceProvisioningState? provisioningState = null, string alertRuleTemplateId = null, string alertRuleTemplateVersion = null) + public static DatabaseWatcherAlertRuleProperties DatabaseWatcherAlertRuleProperties(ResourceIdentifier alertRuleResourceId = default, AlertRuleCreationProperty createdWithProperties = default, DateTimeOffset createdOn = default, DatabaseWatcherResourceProvisioningState? provisioningState = default, string alertRuleTemplateId = default, string alertRuleTemplateVersion = default) { return new DatabaseWatcherAlertRuleProperties( alertRuleResourceId, @@ -88,48 +103,48 @@ public static DatabaseWatcherAlertRuleProperties DatabaseWatcherAlertRulePropert provisioningState, alertRuleTemplateId, alertRuleTemplateVersion, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + /// 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. /// The resource-specific properties for this resource. /// A new instance for mocking. - public static DatabaseWatcherHealthValidationData DatabaseWatcherHealthValidationData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, DatabaseWatcherHealthValidationProperties properties = null) + public static DatabaseWatcherHealthValidationData DatabaseWatcherHealthValidationData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, DatabaseWatcherHealthValidationProperties properties = default) { return new DatabaseWatcherHealthValidationData( id, name, resourceType, systemData, - properties, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null, + properties); } - /// Initializes a new instance of . + /// The generic properties of the health validation resource. /// The start time of health validation, in UTC. /// The end time of health validation, in UTC. /// The current health validation status. /// The list of issues found by health validation. /// The provisioning state of the health validation resource. /// A new instance for mocking. - public static DatabaseWatcherHealthValidationProperties DatabaseWatcherHealthValidationProperties(DateTimeOffset startOn = default, DateTimeOffset endOn = default, DatabaseWatcherHealthValidationStatus status = default, IEnumerable issues = null, DatabaseWatcherResourceProvisioningState? provisioningState = null) + public static DatabaseWatcherHealthValidationProperties DatabaseWatcherHealthValidationProperties(DateTimeOffset startOn = default, DateTimeOffset endOn = default, DatabaseWatcherHealthValidationStatus status = default, IEnumerable issues = default, DatabaseWatcherResourceProvisioningState? provisioningState = default) { - issues ??= new List(); + issues ??= new ChangeTrackingList(); return new DatabaseWatcherHealthValidationProperties( startOn, endOn, status, - issues?.ToList(), + issues.ToList(), provisioningState, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The model of a health validation issue. /// The error code of the issue. /// The error message of the issue. /// The additional details for the issue. @@ -138,7 +153,7 @@ public static DatabaseWatcherHealthValidationProperties DatabaseWatcherHealthVal /// The resource ID of the Azure resource related to the issue. /// The type of the Azure resource related to the issue. /// A new instance for mocking. - public static DatabaseWatcherHealthValidationIssue DatabaseWatcherHealthValidationIssue(string errorCode = null, string errorMessage = null, string additionalDetails = null, string recommendationMessage = null, Uri recommendationUri = null, ResourceIdentifier relatedResourceId = null, ResourceType? relatedResourceType = null) + public static DatabaseWatcherHealthValidationIssue DatabaseWatcherHealthValidationIssue(string errorCode = default, string errorMessage = default, string additionalDetails = default, string recommendationMessage = default, Uri recommendationUri = default, ResourceIdentifier relatedResourceId = default, ResourceType? relatedResourceType = default) { return new DatabaseWatcherHealthValidationIssue( errorCode, @@ -148,39 +163,38 @@ public static DatabaseWatcherHealthValidationIssue DatabaseWatcherHealthValidati recommendationUri, relatedResourceId, relatedResourceType, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// - /// The resource-specific properties for this resource. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . - /// + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + /// 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. + /// The resource-specific properties for this resource. /// A new instance for mocking. - public static DatabaseWatcherTargetData DatabaseWatcherTargetData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, DatabaseWatcherTargetProperties properties = null) + public static DatabaseWatcherTargetData DatabaseWatcherTargetData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, DatabaseWatcherTargetProperties properties = default) { return new DatabaseWatcherTargetData( id, name, resourceType, systemData, - properties, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null, + properties); } - /// Initializes a new instance of . + /// + /// The generic properties of a target. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// /// Discriminator property for DatabaseWatcherTargetProperties. /// The type of authentication to use when connecting to a target. /// To use SQL authentication when connecting to targets, specify the vault where the login name and password secrets are stored. /// The FQDN host name of the server to use in the connection string when connecting to a target. For example, for an Azure SQL logical server in the Azure commercial cloud, the value might be 'sql-logical-server-22092780.database.windows.net'; for an Azure SQL managed instance in the Azure commercial cloud, the value might be 'sql-mi-39441134.767d5869f605.database.windows.net'. Port number and instance name must be specified separately. /// The provisioning state of the resource. /// A new instance for mocking. - public static DatabaseWatcherTargetProperties DatabaseWatcherTargetProperties(string targetType = null, TargetAuthenticationType targetAuthenticationType = default, TargetAuthenticationVaultSecret targetVault = null, string connectionServerName = null, DatabaseWatcherResourceProvisioningState? provisioningState = null) + public static DatabaseWatcherTargetProperties DatabaseWatcherTargetProperties(string targetType = default, TargetAuthenticationType targetAuthenticationType = default, TargetAuthenticationVaultSecret targetVault = default, string connectionServerName = default, DatabaseWatcherResourceProvisioningState? provisioningState = default) { return new UnknownDatabaseWatcherTargetProperties( targetType, @@ -188,10 +202,10 @@ public static DatabaseWatcherTargetProperties DatabaseWatcherTargetProperties(st targetVault, connectionServerName, provisioningState, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } - /// Initializes a new instance of . + /// The properties specific to a database in Azure SQL Database. /// The type of authentication to use when connecting to a target. /// To use SQL authentication when connecting to targets, specify the vault where the login name and password secrets are stored. /// The FQDN host name of the server to use in the connection string when connecting to a target. For example, for an Azure SQL logical server in the Azure commercial cloud, the value might be 'sql-logical-server-22092780.database.windows.net'; for an Azure SQL managed instance in the Azure commercial cloud, the value might be 'sql-mi-39441134.767d5869f605.database.windows.net'. Port number and instance name must be specified separately. @@ -199,7 +213,7 @@ public static DatabaseWatcherTargetProperties DatabaseWatcherTargetProperties(st /// The Azure resource ID of an Azure SQL DB database target. /// Set to true to monitor a high availability replica of specified target, if any. /// A new instance for mocking. - public static SqlDBSingleDatabaseTargetProperties SqlDBSingleDatabaseTargetProperties(TargetAuthenticationType targetAuthenticationType = default, TargetAuthenticationVaultSecret targetVault = null, string connectionServerName = null, DatabaseWatcherResourceProvisioningState? provisioningState = null, ResourceIdentifier sqlDbResourceId = null, bool? readIntent = null) + public static SqlDBSingleDatabaseTargetProperties SqlDBSingleDatabaseTargetProperties(TargetAuthenticationType targetAuthenticationType = default, TargetAuthenticationVaultSecret targetVault = default, string connectionServerName = default, DatabaseWatcherResourceProvisioningState? provisioningState = default, ResourceIdentifier sqlDbResourceId = default, bool? readIntent = default) { return new SqlDBSingleDatabaseTargetProperties( "SqlDb", @@ -207,12 +221,12 @@ public static SqlDBSingleDatabaseTargetProperties SqlDBSingleDatabaseTargetPrope targetVault, connectionServerName, provisioningState, - serializedAdditionalRawData: null, + additionalBinaryDataProperties: null, sqlDbResourceId, readIntent); } - /// Initializes a new instance of . + /// The properties specific to an elastic pool in Azure SQL Database. /// The type of authentication to use when connecting to a target. /// To use SQL authentication when connecting to targets, specify the vault where the login name and password secrets are stored. /// The FQDN host name of the server to use in the connection string when connecting to a target. For example, for an Azure SQL logical server in the Azure commercial cloud, the value might be 'sql-logical-server-22092780.database.windows.net'; for an Azure SQL managed instance in the Azure commercial cloud, the value might be 'sql-mi-39441134.767d5869f605.database.windows.net'. Port number and instance name must be specified separately. @@ -221,7 +235,7 @@ public static SqlDBSingleDatabaseTargetProperties SqlDBSingleDatabaseTargetPrope /// The Azure resource ID of the anchor database used to connect to an elastic pool. /// Set to true to monitor a high availability replica of specified target, if any. /// A new instance for mocking. - public static SqlDBElasticPoolTargetProperties SqlDBElasticPoolTargetProperties(TargetAuthenticationType targetAuthenticationType = default, TargetAuthenticationVaultSecret targetVault = null, string connectionServerName = null, DatabaseWatcherResourceProvisioningState? provisioningState = null, ResourceIdentifier sqlEpResourceId = null, ResourceIdentifier anchorDatabaseResourceId = null, bool? readIntent = null) + public static SqlDBElasticPoolTargetProperties SqlDBElasticPoolTargetProperties(TargetAuthenticationType targetAuthenticationType = default, TargetAuthenticationVaultSecret targetVault = default, string connectionServerName = default, DatabaseWatcherResourceProvisioningState? provisioningState = default, ResourceIdentifier sqlEpResourceId = default, ResourceIdentifier anchorDatabaseResourceId = default, bool? readIntent = default) { return new SqlDBElasticPoolTargetProperties( "SqlEp", @@ -229,13 +243,13 @@ public static SqlDBElasticPoolTargetProperties SqlDBElasticPoolTargetProperties( targetVault, connectionServerName, provisioningState, - serializedAdditionalRawData: null, + additionalBinaryDataProperties: null, sqlEpResourceId, anchorDatabaseResourceId, readIntent); } - /// Initializes a new instance of . + /// The properties specific to Azure SQL Managed Instance targets. /// The type of authentication to use when connecting to a target. /// To use SQL authentication when connecting to targets, specify the vault where the login name and password secrets are stored. /// The FQDN host name of the server to use in the connection string when connecting to a target. For example, for an Azure SQL logical server in the Azure commercial cloud, the value might be 'sql-logical-server-22092780.database.windows.net'; for an Azure SQL managed instance in the Azure commercial cloud, the value might be 'sql-mi-39441134.767d5869f605.database.windows.net'. Port number and instance name must be specified separately. @@ -244,7 +258,7 @@ public static SqlDBElasticPoolTargetProperties SqlDBElasticPoolTargetProperties( /// The TCP port number to optionally use in the connection string when connecting to an Azure SQL Managed Instance target. /// Set to true to monitor a high availability replica of specified target, if any. /// A new instance for mocking. - public static SqlMITargetProperties SqlMITargetProperties(TargetAuthenticationType targetAuthenticationType = default, TargetAuthenticationVaultSecret targetVault = null, string connectionServerName = null, DatabaseWatcherResourceProvisioningState? provisioningState = null, ResourceIdentifier sqlMiResourceId = null, int? connectionTcpPort = null, bool? readIntent = null) + public static SqlMITargetProperties SqlMITargetProperties(TargetAuthenticationType targetAuthenticationType = default, TargetAuthenticationVaultSecret targetVault = default, string connectionServerName = default, DatabaseWatcherResourceProvisioningState? provisioningState = default, ResourceIdentifier sqlMiResourceId = default, int? connectionTcpPort = default, bool? readIntent = default) { return new SqlMITargetProperties( "SqlMi", @@ -252,31 +266,31 @@ public static SqlMITargetProperties SqlMITargetProperties(TargetAuthenticationTy targetVault, connectionServerName, provisioningState, - serializedAdditionalRawData: null, + additionalBinaryDataProperties: null, sqlMiResourceId, connectionTcpPort, readIntent); } - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + /// 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. /// The resource-specific properties for this resource. /// A new instance for mocking. - public static DatabaseWatcherSharedPrivateLinkResourceData DatabaseWatcherSharedPrivateLinkResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, DatabaseWatcherSharedPrivateLinkResourceProperties properties = null) + public static DatabaseWatcherSharedPrivateLinkResourceData DatabaseWatcherSharedPrivateLinkResourceData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, DatabaseWatcherSharedPrivateLinkResourceProperties properties = default) { return new DatabaseWatcherSharedPrivateLinkResourceData( id, name, resourceType, systemData, - properties, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null, + properties); } - /// Initializes a new instance of . + /// The generic properties of a Shared Private Link resource. /// The resource ID of the resource the shared private link resource is for. /// The group id from the provider of resource the shared private link resource is for. /// The request message for requesting approval of the shared private link resource. @@ -284,7 +298,7 @@ public static DatabaseWatcherSharedPrivateLinkResourceData DatabaseWatcherShared /// Status of the shared private link resource. Can be Pending, Approved, Rejected or Disconnected. /// The provisioning state of the resource. /// A new instance for mocking. - public static DatabaseWatcherSharedPrivateLinkResourceProperties DatabaseWatcherSharedPrivateLinkResourceProperties(ResourceIdentifier privateLinkResourceId = null, string groupId = null, string requestMessage = null, string dnsZone = null, DatabaseWatcherSharedPrivateLinkResourceStatus? status = null, DatabaseWatcherResourceProvisioningState? provisioningState = null) + public static DatabaseWatcherSharedPrivateLinkResourceProperties DatabaseWatcherSharedPrivateLinkResourceProperties(ResourceIdentifier privateLinkResourceId = default, string groupId = default, string requestMessage = default, string dnsZone = default, DatabaseWatcherSharedPrivateLinkResourceStatus? status = default, DatabaseWatcherResourceProvisioningState? provisioningState = default) { return new DatabaseWatcherSharedPrivateLinkResourceProperties( privateLinkResourceId, @@ -293,7 +307,7 @@ public static DatabaseWatcherSharedPrivateLinkResourceProperties DatabaseWatcher dnsZone, status, provisioningState, - serializedAdditionalRawData: null); + additionalBinaryDataProperties: null); } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleCollection.cs index ea81ae0c8683..6d84c2934bc2 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleCollection.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleCollection.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; namespace Azure.ResourceManager.DatabaseWatcher { @@ -24,51 +25,49 @@ namespace Azure.ResourceManager.DatabaseWatcher /// public partial class DatabaseWatcherAlertRuleCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics; - private readonly AlertRuleResourcesRestOperations _databaseWatcherAlertRuleAlertRuleResourcesRestClient; + private readonly ClientDiagnostics _alertRuleResourcesClientDiagnostics; + private readonly AlertRuleResources _alertRuleResourcesRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DatabaseWatcherAlertRuleCollection for mocking. protected DatabaseWatcherAlertRuleCollection() { } - /// 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 DatabaseWatcherAlertRuleCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", DatabaseWatcherAlertRuleResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(DatabaseWatcherAlertRuleResource.ResourceType, out string databaseWatcherAlertRuleAlertRuleResourcesApiVersion); - _databaseWatcherAlertRuleAlertRuleResourcesRestClient = new AlertRuleResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, databaseWatcherAlertRuleAlertRuleResourcesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(DatabaseWatcherAlertRuleResource.ResourceType, out string databaseWatcherAlertRuleApiVersion); + _alertRuleResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", DatabaseWatcherAlertRuleResource.ResourceType.Namespace, Diagnostics); + _alertRuleResourcesRestClient = new AlertRuleResources(_alertRuleResourcesClientDiagnostics, Pipeline, Endpoint, databaseWatcherAlertRuleApiVersion ?? "2025-01-02"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != DatabaseWatcherResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, DatabaseWatcherResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, DatabaseWatcherResource.ResourceType), id); + } } /// /// Create a AlertRuleResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} - /// - /// - /// Operation Id - /// AlertRuleResource_CreateOrUpdate + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// AlertRuleResources_CreateOrUpdate. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -76,23 +75,31 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// The alert rule proxy resource name. /// Resource create parameters. /// 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 alertRuleResourceName, DatabaseWatcherAlertRuleData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.CreateOrUpdate"); + using DiagnosticScope scope = _alertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _databaseWatcherAlertRuleAlertRuleResourcesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, data, cancellationToken).ConfigureAwait(false); - var uri = _databaseWatcherAlertRuleAlertRuleResourcesRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherAlertRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _alertRuleResourcesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, alertRuleResourceName, DatabaseWatcherAlertRuleData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherAlertRuleData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherAlertRuleResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -106,20 +113,16 @@ public virtual async Task> Create /// Create a AlertRuleResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}. /// /// - /// Operation Id - /// AlertRuleResource_CreateOrUpdate + /// Operation Id. + /// AlertRuleResources_CreateOrUpdate. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -127,23 +130,31 @@ public virtual async Task> Create /// The alert rule proxy resource name. /// Resource create parameters. /// 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 alertRuleResourceName, DatabaseWatcherAlertRuleData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.CreateOrUpdate"); + using DiagnosticScope scope = _alertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.CreateOrUpdate"); scope.Start(); try { - var response = _databaseWatcherAlertRuleAlertRuleResourcesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, data, cancellationToken); - var uri = _databaseWatcherAlertRuleAlertRuleResourcesRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherAlertRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _alertRuleResourcesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, alertRuleResourceName, DatabaseWatcherAlertRuleData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherAlertRuleData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherAlertRuleResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -157,38 +168,42 @@ public virtual ArmOperation CreateOrUpdate(Wai /// Get a AlertRuleResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} - /// - /// - /// Operation Id - /// AlertRuleResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// AlertRuleResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The alert rule proxy resource name. /// 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 alertRuleResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); - using var scope = _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.Get"); + using DiagnosticScope scope = _alertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.Get"); scope.Start(); try { - var response = await _databaseWatcherAlertRuleAlertRuleResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _alertRuleResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, alertRuleResourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherAlertRuleData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherAlertRuleResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -202,38 +217,42 @@ public virtual async Task> GetAsync(s /// Get a AlertRuleResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} - /// - /// - /// Operation Id - /// AlertRuleResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// AlertRuleResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The alert rule proxy resource name. /// 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 alertRuleResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); - using var scope = _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.Get"); + using DiagnosticScope scope = _alertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.Get"); scope.Start(); try { - var response = _databaseWatcherAlertRuleAlertRuleResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _alertRuleResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, alertRuleResourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherAlertRuleData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherAlertRuleResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -247,50 +266,44 @@ public virtual Response Get(string alertRuleRe /// List AlertRuleResource resources by Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources. /// /// - /// Operation Id - /// AlertRuleResource_ListByParent + /// Operation Id. + /// AlertRuleResources_ListByParent. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// 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) => _databaseWatcherAlertRuleAlertRuleResourcesRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _databaseWatcherAlertRuleAlertRuleResourcesRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DatabaseWatcherAlertRuleResource(Client, DatabaseWatcherAlertRuleData.DeserializeDatabaseWatcherAlertRuleData(e)), _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics, Pipeline, "DatabaseWatcherAlertRuleCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new AlertRuleResourcesGetByParentAsyncCollectionResultOfT(_alertRuleResourcesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new DatabaseWatcherAlertRuleResource(Client, data)); } /// /// List AlertRuleResource resources by Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources - /// - /// - /// Operation Id - /// AlertRuleResource_ListByParent + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// AlertRuleResources_ListByParent. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -298,45 +311,61 @@ public virtual AsyncPageable GetAllAsync(Cance /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _databaseWatcherAlertRuleAlertRuleResourcesRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _databaseWatcherAlertRuleAlertRuleResourcesRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DatabaseWatcherAlertRuleResource(Client, DatabaseWatcherAlertRuleData.DeserializeDatabaseWatcherAlertRuleData(e)), _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics, Pipeline, "DatabaseWatcherAlertRuleCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new AlertRuleResourcesGetByParentCollectionResultOfT(_alertRuleResourcesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new DatabaseWatcherAlertRuleResource(Client, data)); } /// - /// Checks to see if the resource exists in azure. + /// Get a AlertRuleResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}. /// /// - /// Operation Id - /// AlertRuleResource_Get + /// Operation Id. + /// AlertRuleResources_Get. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The alert rule proxy resource name. /// 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 alertRuleResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); - using var scope = _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.Exists"); + using DiagnosticScope scope = _alertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.Exists"); scope.Start(); try { - var response = await _databaseWatcherAlertRuleAlertRuleResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _alertRuleResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, alertRuleResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherAlertRuleData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherAlertRuleData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -347,39 +376,53 @@ public virtual async Task> ExistsAsync(string alertRuleResourceNa } /// - /// Checks to see if the resource exists in azure. + /// Get a AlertRuleResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} - /// - /// - /// Operation Id - /// AlertRuleResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// AlertRuleResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The alert rule proxy resource name. /// 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 alertRuleResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); - using var scope = _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.Exists"); + using DiagnosticScope scope = _alertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.Exists"); scope.Start(); try { - var response = _databaseWatcherAlertRuleAlertRuleResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _alertRuleResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, alertRuleResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherAlertRuleData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherAlertRuleData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -390,41 +433,57 @@ public virtual Response Exists(string alertRuleResourceName, CancellationT } /// - /// Tries to get details for this resource from the service. + /// Get a AlertRuleResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} - /// - /// - /// Operation Id - /// AlertRuleResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// AlertRuleResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The alert rule proxy resource name. /// 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 alertRuleResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); - using var scope = _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.GetIfExists"); + using DiagnosticScope scope = _alertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.GetIfExists"); scope.Start(); try { - var response = await _databaseWatcherAlertRuleAlertRuleResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _alertRuleResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, alertRuleResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherAlertRuleData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherAlertRuleData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherAlertRuleResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -435,41 +494,57 @@ public virtual async Task> Ge } /// - /// Tries to get details for this resource from the service. + /// Get a AlertRuleResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}. /// /// - /// Operation Id - /// AlertRuleResource_Get + /// Operation Id. + /// AlertRuleResources_Get. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The alert rule proxy resource name. /// 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 alertRuleResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); - using var scope = _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.GetIfExists"); + using DiagnosticScope scope = _alertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleCollection.GetIfExists"); scope.Start(); try { - var response = _databaseWatcherAlertRuleAlertRuleResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _alertRuleResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, alertRuleResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherAlertRuleData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherAlertRuleData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherAlertRuleResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -489,6 +564,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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleData.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleData.Serialization.cs index 131fe6b2e99b..d1270ef6ba26 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleData.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleData.Serialization.cs @@ -10,16 +10,18 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.DatabaseWatcher.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DatabaseWatcher { - public partial class DatabaseWatcherAlertRuleData : IUtf8JsonSerializable, IJsonModel + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + public partial class DatabaseWatcherAlertRuleData : ResourceData, 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(); @@ -31,12 +33,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// 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(DatabaseWatcherAlertRuleData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Properties)) { @@ -45,87 +46,101 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DatabaseWatcherAlertRuleData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherAlertRuleData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DatabaseWatcherAlertRuleData)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(DatabaseWatcherAlertRuleData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherAlertRuleData(document.RootElement, options); } - internal static DatabaseWatcherAlertRuleData DeserializeDatabaseWatcherAlertRuleData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DatabaseWatcherAlertRuleData DeserializeDatabaseWatcherAlertRuleData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DatabaseWatcherAlertRuleProperties properties = 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(); + DatabaseWatcherAlertRuleProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = DatabaseWatcherAlertRuleProperties.DeserializeDatabaseWatcherAlertRuleProperties(property.Value, options); + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("name"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("type"u8)) { - name = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("systemData"u8)) { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDatabaseWatcherContext.Default); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("properties"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, AzureResourceManagerDatabaseWatcherContext.Default); + properties = DatabaseWatcherAlertRuleProperties.DeserializeDatabaseWatcherAlertRuleProperties(prop.Value, options); 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 DatabaseWatcherAlertRuleData( id, name, - type, + resourceType, systemData, - properties, - serializedAdditionalRawData); + additionalBinaryDataProperties, + properties); } - 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 +150,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - DatabaseWatcherAlertRuleData 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. + DatabaseWatcherAlertRuleData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DatabaseWatcherAlertRuleData)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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherAlertRuleData(document.RootElement, options); } default: @@ -151,6 +171,27 @@ DatabaseWatcherAlertRuleData IPersistableModel.Cre } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DatabaseWatcherAlertRuleData databaseWatcherAlertRuleData) + { + if (databaseWatcherAlertRuleData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(databaseWatcherAlertRuleData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static DatabaseWatcherAlertRuleData FromResponse(Response result) + { + using Response response = result; + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeDatabaseWatcherAlertRuleData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleData.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleData.cs index bf437fd51e74..085a326dc8cb 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleData.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleData.cs @@ -13,43 +13,11 @@ namespace Azure.ResourceManager.DatabaseWatcher { - /// - /// A class representing the DatabaseWatcherAlertRule data model. - /// Concrete proxy resource types can be created by aliasing this type using a specific property type. - /// + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. public partial class DatabaseWatcherAlertRuleData : ResourceData { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public DatabaseWatcherAlertRuleData() @@ -57,16 +25,16 @@ public DatabaseWatcherAlertRuleData() } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// 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. /// The resource-specific properties for this resource. - /// Keeps track of any properties unknown to the library. - internal DatabaseWatcherAlertRuleData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, DatabaseWatcherAlertRuleProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + internal DatabaseWatcherAlertRuleData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, DatabaseWatcherAlertRuleProperties properties) : base(id, name, resourceType, systemData) { + _additionalBinaryDataProperties = additionalBinaryDataProperties; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; } /// The resource-specific properties for this resource. diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleResource.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleResource.Serialization.cs index 7e42f9b4938f..eb1047c8602c 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleResource.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.DatabaseWatcher { + /// public partial class DatabaseWatcherAlertRuleResource : IJsonModel { - private static DatabaseWatcherAlertRuleData s_dataDeserializationInstance; - private static DatabaseWatcherAlertRuleData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new DatabaseWatcherAlertRuleData(); + + /// 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); - DatabaseWatcherAlertRuleData 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. + DatabaseWatcherAlertRuleData 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, AzureResourceManagerDatabaseWatcherContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. DatabaseWatcherAlertRuleData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDatabaseWatcherContext.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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleResource.cs index ba6e5d92a404..7a2f4f7bec56 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleResource.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherAlertRuleResource.cs @@ -6,46 +6,35 @@ #nullable disable using System; -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; namespace Azure.ResourceManager.DatabaseWatcher { /// - /// A Class representing a DatabaseWatcherAlertRule 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 GetDatabaseWatcherAlertRuleResource method. - /// Otherwise you can get one from its parent resource using the GetDatabaseWatcherAlertRule method. + /// A class representing a DatabaseWatcherAlertRule 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 GetDatabaseWatcherAlertRules method. /// public partial class DatabaseWatcherAlertRuleResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The watcherName. - /// The alertRuleResourceName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics; - private readonly AlertRuleResourcesRestOperations _databaseWatcherAlertRuleAlertRuleResourcesRestClient; + private readonly ClientDiagnostics _alertRuleResourcesClientDiagnostics; + private readonly AlertRuleResources _alertRuleResourcesRestClient; private readonly DatabaseWatcherAlertRuleData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.DatabaseWatcher/watchers/alertRuleResources"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DatabaseWatcherAlertRuleResource for mocking. protected DatabaseWatcherAlertRuleResource() { } - /// 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 DatabaseWatcherAlertRuleResource(ArmClient client, DatabaseWatcherAlertRuleData data) : this(client, data.Id) @@ -54,71 +43,93 @@ internal DatabaseWatcherAlertRuleResource(ArmClient client, DatabaseWatcherAlert _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 DatabaseWatcherAlertRuleResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string databaseWatcherAlertRuleAlertRuleResourcesApiVersion); - _databaseWatcherAlertRuleAlertRuleResourcesRestClient = new AlertRuleResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, databaseWatcherAlertRuleAlertRuleResourcesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string databaseWatcherAlertRuleApiVersion); + _alertRuleResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); + _alertRuleResourcesRestClient = new AlertRuleResources(_alertRuleResourcesClientDiagnostics, Pipeline, Endpoint, databaseWatcherAlertRuleApiVersion ?? "2025-01-02"); + 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 DatabaseWatcherAlertRuleData 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 watcherName. + /// The alertRuleResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}"; + 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 AlertRuleResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}. /// /// - /// Operation Id - /// AlertRuleResource_Get + /// Operation Id. + /// AlertRuleResources_Get. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleResource.Get"); + using DiagnosticScope scope = _alertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleResource.Get"); scope.Start(); try { - var response = await _databaseWatcherAlertRuleAlertRuleResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _alertRuleResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherAlertRuleData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherAlertRuleResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -132,33 +143,41 @@ public virtual async Task> GetAsync(C /// Get a AlertRuleResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}. /// /// - /// Operation Id - /// AlertRuleResource_Get + /// Operation Id. + /// AlertRuleResources_Get. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleResource.Get"); + using DiagnosticScope scope = _alertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleResource.Get"); scope.Start(); try { - var response = _databaseWatcherAlertRuleAlertRuleResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _alertRuleResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherAlertRuleData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherAlertRuleResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -172,20 +191,20 @@ public virtual Response Get(CancellationToken /// Delete a AlertRuleResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}. /// /// - /// Operation Id - /// AlertRuleResource_Delete + /// Operation Id. + /// AlertRuleResources_Delete. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -193,16 +212,23 @@ public virtual Response Get(CancellationToken /// The cancellation token to use. public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleResource.Delete"); + using DiagnosticScope scope = _alertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleResource.Delete"); scope.Start(); try { - var response = await _databaseWatcherAlertRuleAlertRuleResourcesRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var uri = _databaseWatcherAlertRuleAlertRuleResourcesRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DatabaseWatcherArmOperation(response, rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _alertRuleResourcesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(response, rehydrationToken); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -216,20 +242,20 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// Delete a AlertRuleResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}. /// /// - /// Operation Id - /// AlertRuleResource_Delete + /// Operation Id. + /// AlertRuleResources_Delete. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -237,16 +263,23 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// The cancellation token to use. public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleResource.Delete"); + using DiagnosticScope scope = _alertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleResource.Delete"); scope.Start(); try { - var response = _databaseWatcherAlertRuleAlertRuleResourcesRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var uri = _databaseWatcherAlertRuleAlertRuleResourcesRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DatabaseWatcherArmOperation(response, rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _alertRuleResourcesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(response, rehydrationToken); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletionResponse(cancellationToken); + } return operation; } catch (Exception e) @@ -260,20 +293,20 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// Create a AlertRuleResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}. /// /// - /// Operation Id - /// AlertRuleResource_CreateOrUpdate + /// Operation Id. + /// AlertRuleResources_CreateOrUpdate. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -285,16 +318,24 @@ public virtual async Task> Update { Argument.AssertNotNull(data, nameof(data)); - using var scope = _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleResource.Update"); + using DiagnosticScope scope = _alertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleResource.Update"); scope.Start(); try { - var response = await _databaseWatcherAlertRuleAlertRuleResourcesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); - var uri = _databaseWatcherAlertRuleAlertRuleResourcesRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherAlertRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _alertRuleResourcesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, DatabaseWatcherAlertRuleData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherAlertRuleData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherAlertRuleResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -308,20 +349,20 @@ public virtual async Task> Update /// Create a AlertRuleResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName}. /// /// - /// Operation Id - /// AlertRuleResource_CreateOrUpdate + /// Operation Id. + /// AlertRuleResources_CreateOrUpdate. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -333,16 +374,24 @@ public virtual ArmOperation Update(WaitUntil w { Argument.AssertNotNull(data, nameof(data)); - using var scope = _databaseWatcherAlertRuleAlertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleResource.Update"); + using DiagnosticScope scope = _alertRuleResourcesClientDiagnostics.CreateScope("DatabaseWatcherAlertRuleResource.Update"); scope.Start(); try { - var response = _databaseWatcherAlertRuleAlertRuleResourcesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); - var uri = _databaseWatcherAlertRuleAlertRuleResourcesRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherAlertRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _alertRuleResourcesRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, DatabaseWatcherAlertRuleData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherAlertRuleData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherAlertRuleResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherCollection.cs index 0bff50e0233d..5bd3367866cc 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherCollection.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherCollection.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.DatabaseWatcher @@ -25,51 +26,49 @@ namespace Azure.ResourceManager.DatabaseWatcher /// public partial class DatabaseWatcherCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _databaseWatcherWatchersClientDiagnostics; - private readonly WatchersRestOperations _databaseWatcherWatchersRestClient; + private readonly ClientDiagnostics _watchersClientDiagnostics; + private readonly Watchers _watchersRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DatabaseWatcherCollection for mocking. protected DatabaseWatcherCollection() { } - /// 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 DatabaseWatcherCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _databaseWatcherWatchersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", DatabaseWatcherResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(DatabaseWatcherResource.ResourceType, out string databaseWatcherWatchersApiVersion); - _databaseWatcherWatchersRestClient = new WatchersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, databaseWatcherWatchersApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(DatabaseWatcherResource.ResourceType, out string databaseWatcherApiVersion); + _watchersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", DatabaseWatcherResource.ResourceType.Namespace, Diagnostics); + _watchersRestClient = new Watchers(_watchersClientDiagnostics, Pipeline, Endpoint, databaseWatcherApiVersion ?? "2025-01-02"); + 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 Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_CreateOrUpdate + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Watchers_CreateOrUpdate. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -77,21 +76,34 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// The database watcher name. /// Resource create parameters. /// 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 watcherName, DatabaseWatcherData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.CreateOrUpdate"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _databaseWatcherWatchersRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, watcherName, data, cancellationToken).ConfigureAwait(false); - var operation = new DatabaseWatcherArmOperation(new DatabaseWatcherOperationSource(Client), _databaseWatcherWatchersClientDiagnostics, Pipeline, _databaseWatcherWatchersRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, watcherName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, watcherName, DatabaseWatcherData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation( + new DatabaseWatcherOperationSource(Client), + _watchersClientDiagnostics, + 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> CreateOrUpdateA /// Create a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Operation Id - /// Watcher_CreateOrUpdate + /// Operation Id. + /// Watchers_CreateOrUpdate. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -126,21 +134,34 @@ public virtual async Task> CreateOrUpdateA /// The database watcher name. /// Resource create parameters. /// 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 watcherName, DatabaseWatcherData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.CreateOrUpdate"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.CreateOrUpdate"); scope.Start(); try { - var response = _databaseWatcherWatchersRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, watcherName, data, cancellationToken); - var operation = new DatabaseWatcherArmOperation(new DatabaseWatcherOperationSource(Client), _databaseWatcherWatchersClientDiagnostics, Pipeline, _databaseWatcherWatchersRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, watcherName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, watcherName, DatabaseWatcherData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation( + new DatabaseWatcherOperationSource(Client), + _watchersClientDiagnostics, + 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 wa /// Get a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Watchers_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The database watcher name. /// 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 watcherName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.Get"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.Get"); scope.Start(); try { - var response = await _databaseWatcherWatchersRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, watcherName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, watcherName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -199,38 +224,42 @@ public virtual async Task> GetAsync(string wat /// Get a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Watchers_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The database watcher name. /// 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 watcherName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.Get"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.Get"); scope.Start(); try { - var response = _databaseWatcherWatchersRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, watcherName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, watcherName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -244,50 +273,44 @@ public virtual Response Get(string watcherName, Cancell /// List Watcher resources by resource group /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers. /// /// - /// Operation Id - /// Watcher_ListByResourceGroup + /// Operation Id. + /// Watchers_ListByResourceGroup. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// 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) => _databaseWatcherWatchersRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _databaseWatcherWatchersRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DatabaseWatcherResource(Client, DatabaseWatcherData.DeserializeDatabaseWatcherData(e)), _databaseWatcherWatchersClientDiagnostics, Pipeline, "DatabaseWatcherCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new WatchersGetByResourceGroupAsyncCollectionResultOfT(_watchersRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new DatabaseWatcherResource(Client, data)); } /// /// List Watcher resources by resource group /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers - /// - /// - /// Operation Id - /// Watcher_ListByResourceGroup + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Watchers_ListByResourceGroup. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -295,45 +318,61 @@ public virtual AsyncPageable GetAllAsync(CancellationTo /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _databaseWatcherWatchersRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _databaseWatcherWatchersRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DatabaseWatcherResource(Client, DatabaseWatcherData.DeserializeDatabaseWatcherData(e)), _databaseWatcherWatchersClientDiagnostics, Pipeline, "DatabaseWatcherCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new WatchersGetByResourceGroupCollectionResultOfT(_watchersRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, context), data => new DatabaseWatcherResource(Client, data)); } /// - /// Checks to see if the resource exists in azure. + /// Get a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Operation Id - /// Watcher_Get + /// Operation Id. + /// Watchers_Get. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The database watcher name. /// 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 watcherName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.Exists"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.Exists"); scope.Start(); try { - var response = await _databaseWatcherWatchersRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, watcherName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, watcherName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -344,39 +383,53 @@ public virtual async Task> ExistsAsync(string watcherName, Cancel } /// - /// Checks to see if the resource exists in azure. + /// Get a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Watchers_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The database watcher name. /// 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 watcherName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.Exists"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.Exists"); scope.Start(); try { - var response = _databaseWatcherWatchersRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, watcherName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, watcherName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -387,41 +440,57 @@ public virtual Response Exists(string watcherName, CancellationToken cance } /// - /// Tries to get details for this resource from the service. + /// Get a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Watchers_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The database watcher name. /// 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 watcherName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.GetIfExists"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.GetIfExists"); scope.Start(); try { - var response = await _databaseWatcherWatchersRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, watcherName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, watcherName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -432,41 +501,57 @@ public virtual async Task> GetIfExists } /// - /// Tries to get details for this resource from the service. + /// Get a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Operation Id - /// Watcher_Get + /// Operation Id. + /// Watchers_Get. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The database watcher name. /// 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 watcherName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.GetIfExists"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherCollection.GetIfExists"); scope.Start(); try { - var response = _databaseWatcherWatchersRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, watcherName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, watcherName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherResource(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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherData.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherData.Serialization.cs index b3f1649487c4..e3ff59d07f9a 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherData.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherData.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.DatabaseWatcher.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DatabaseWatcher { - public partial class DatabaseWatcherData : IUtf8JsonSerializable, IJsonModel + /// The DatabaseWatcherProviderHub resource. + public partial class DatabaseWatcherData : TrackedResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DatabaseWatcherData() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,12 +38,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri /// 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(DatabaseWatcherData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Properties)) { @@ -50,121 +56,142 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DatabaseWatcherData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DatabaseWatcherData)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(DatabaseWatcherData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherData(document.RootElement, options); } - internal static DatabaseWatcherData DeserializeDatabaseWatcherData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DatabaseWatcherData DeserializeDatabaseWatcherData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DatabaseWatcherProperties properties = default; - ManagedServiceIdentity identity = 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; + DatabaseWatcherProperties properties = default; + ManagedServiceIdentity identity = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("id"u8)) + { + 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 (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = DatabaseWatcherProperties.DeserializeDatabaseWatcherProperties(property.Value, options); + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("identity"u8)) + if (prop.NameEquals("systemData"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())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDatabaseWatcherContext.Default); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDatabaseWatcherContext.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)) + if (prop.NameEquals("location"u8)) { - location = new AzureLocation(property.Value.GetString()); + location = new AzureLocation(prop.Value.GetString()); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("properties"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); - continue; - } - if (property.NameEquals("name"u8)) - { - name = property.Value.GetString(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = DatabaseWatcherProperties.DeserializeDatabaseWatcherProperties(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, AzureResourceManagerDatabaseWatcherContext.Default); + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDatabaseWatcherContext.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 DatabaseWatcherData( id, name, - type, + resourceType, systemData, + additionalBinaryDataProperties, tags ?? new ChangeTrackingDictionary(), location, properties, - identity, - serializedAdditionalRawData); + 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": @@ -174,15 +201,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - DatabaseWatcherData 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. + DatabaseWatcherData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DatabaseWatcherData)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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherData(document.RootElement, options); } default: @@ -190,6 +222,27 @@ DatabaseWatcherData IPersistableModel.Create(BinaryData dat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DatabaseWatcherData databaseWatcherData) + { + if (databaseWatcherData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(databaseWatcherData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static DatabaseWatcherData FromResponse(Response result) + { + using Response response = result; + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeDatabaseWatcherData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherData.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherData.cs index e6267edeeec4..8924807da66d 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherData.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherData.cs @@ -13,73 +13,39 @@ namespace Azure.ResourceManager.DatabaseWatcher { - /// - /// A class representing the DatabaseWatcher data model. - /// The DatabaseWatcherProviderHub resource. - /// + /// The DatabaseWatcherProviderHub resource. public partial class DatabaseWatcherData : 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. + /// The geo-location where the resource lives. public DatabaseWatcherData(AzureLocation location) : base(location) { } /// 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 resource-specific properties for this resource. /// The managed service identities assigned to this resource. - /// Keeps track of any properties unknown to the library. - internal DatabaseWatcherData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, DatabaseWatcherProperties properties, ManagedServiceIdentity identity, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + internal DatabaseWatcherData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, DatabaseWatcherProperties properties, ManagedServiceIdentity identity) : base(id, name, resourceType, systemData, tags, location) { + _additionalBinaryDataProperties = additionalBinaryDataProperties; Properties = properties; Identity = identity; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DatabaseWatcherData() - { } /// The resource-specific properties for this resource. public DatabaseWatcherProperties Properties { get; set; } + + /// The managed service identities assigned to this resource. + public ManagedServiceIdentity Identity { get; set; } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationCollection.cs index 27adf21f3f21..3565cfaf9662 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationCollection.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationCollection.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; namespace Azure.ResourceManager.DatabaseWatcher { @@ -24,69 +25,75 @@ namespace Azure.ResourceManager.DatabaseWatcher /// public partial class DatabaseWatcherHealthValidationCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _databaseWatcherHealthValidationHealthValidationsClientDiagnostics; - private readonly HealthValidationsRestOperations _databaseWatcherHealthValidationHealthValidationsRestClient; + private readonly ClientDiagnostics _healthValidationsClientDiagnostics; + private readonly HealthValidations _healthValidationsRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DatabaseWatcherHealthValidationCollection for mocking. protected DatabaseWatcherHealthValidationCollection() { } - /// 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 DatabaseWatcherHealthValidationCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _databaseWatcherHealthValidationHealthValidationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", DatabaseWatcherHealthValidationResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(DatabaseWatcherHealthValidationResource.ResourceType, out string databaseWatcherHealthValidationHealthValidationsApiVersion); - _databaseWatcherHealthValidationHealthValidationsRestClient = new HealthValidationsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, databaseWatcherHealthValidationHealthValidationsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(DatabaseWatcherHealthValidationResource.ResourceType, out string databaseWatcherHealthValidationApiVersion); + _healthValidationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", DatabaseWatcherHealthValidationResource.ResourceType.Namespace, Diagnostics); + _healthValidationsRestClient = new HealthValidations(_healthValidationsClientDiagnostics, Pipeline, Endpoint, databaseWatcherHealthValidationApiVersion ?? "2025-01-02"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != DatabaseWatcherResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, DatabaseWatcherResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, DatabaseWatcherResource.ResourceType), id); + } } /// /// Get a HealthValidation /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}. /// /// - /// Operation Id - /// HealthValidation_Get + /// Operation Id. + /// HealthValidations_Get. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The health validation resource name. /// 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 healthValidationName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); - using var scope = _databaseWatcherHealthValidationHealthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationCollection.Get"); + using DiagnosticScope scope = _healthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationCollection.Get"); scope.Start(); try { - var response = await _databaseWatcherHealthValidationHealthValidationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, healthValidationName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _healthValidationsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, healthValidationName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherHealthValidationData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherHealthValidationResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -100,38 +107,42 @@ public virtual async Task> Get /// Get a HealthValidation /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName} - /// - /// - /// Operation Id - /// HealthValidation_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// HealthValidations_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The health validation resource name. /// 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 healthValidationName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); - using var scope = _databaseWatcherHealthValidationHealthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationCollection.Get"); + using DiagnosticScope scope = _healthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationCollection.Get"); scope.Start(); try { - var response = _databaseWatcherHealthValidationHealthValidationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, healthValidationName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _healthValidationsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, healthValidationName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherHealthValidationData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherHealthValidationResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -145,50 +156,44 @@ public virtual Response Get(string heal /// List HealthValidation resources by Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations. /// /// - /// Operation Id - /// HealthValidation_ListByParent + /// Operation Id. + /// HealthValidations_ListByParent. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// 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) => _databaseWatcherHealthValidationHealthValidationsRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _databaseWatcherHealthValidationHealthValidationsRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DatabaseWatcherHealthValidationResource(Client, DatabaseWatcherHealthValidationData.DeserializeDatabaseWatcherHealthValidationData(e)), _databaseWatcherHealthValidationHealthValidationsClientDiagnostics, Pipeline, "DatabaseWatcherHealthValidationCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new HealthValidationsGetByParentAsyncCollectionResultOfT(_healthValidationsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new DatabaseWatcherHealthValidationResource(Client, data)); } /// /// List HealthValidation resources by Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations. /// /// - /// Operation Id - /// HealthValidation_ListByParent + /// Operation Id. + /// HealthValidations_ListByParent. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -196,45 +201,61 @@ public virtual AsyncPageable GetAllAsyn /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _databaseWatcherHealthValidationHealthValidationsRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _databaseWatcherHealthValidationHealthValidationsRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DatabaseWatcherHealthValidationResource(Client, DatabaseWatcherHealthValidationData.DeserializeDatabaseWatcherHealthValidationData(e)), _databaseWatcherHealthValidationHealthValidationsClientDiagnostics, Pipeline, "DatabaseWatcherHealthValidationCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new HealthValidationsGetByParentCollectionResultOfT(_healthValidationsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new DatabaseWatcherHealthValidationResource(Client, data)); } /// - /// Checks to see if the resource exists in azure. + /// Get a HealthValidation /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName} - /// - /// - /// Operation Id - /// HealthValidation_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// HealthValidations_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The health validation resource name. /// 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 healthValidationName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); - using var scope = _databaseWatcherHealthValidationHealthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationCollection.Exists"); + using DiagnosticScope scope = _healthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationCollection.Exists"); scope.Start(); try { - var response = await _databaseWatcherHealthValidationHealthValidationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, healthValidationName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _healthValidationsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, healthValidationName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherHealthValidationData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherHealthValidationData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -245,39 +266,53 @@ public virtual async Task> ExistsAsync(string healthValidationNam } /// - /// Checks to see if the resource exists in azure. + /// Get a HealthValidation /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName} - /// - /// - /// Operation Id - /// HealthValidation_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// HealthValidations_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The health validation resource name. /// 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 healthValidationName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); - using var scope = _databaseWatcherHealthValidationHealthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationCollection.Exists"); + using DiagnosticScope scope = _healthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationCollection.Exists"); scope.Start(); try { - var response = _databaseWatcherHealthValidationHealthValidationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, healthValidationName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _healthValidationsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, healthValidationName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherHealthValidationData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherHealthValidationData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -288,41 +323,57 @@ public virtual Response Exists(string healthValidationName, CancellationTo } /// - /// Tries to get details for this resource from the service. + /// Get a HealthValidation /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}. /// /// - /// Operation Id - /// HealthValidation_Get + /// Operation Id. + /// HealthValidations_Get. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The health validation resource name. /// 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 healthValidationName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); - using var scope = _databaseWatcherHealthValidationHealthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationCollection.GetIfExists"); + using DiagnosticScope scope = _healthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationCollection.GetIfExists"); scope.Start(); try { - var response = await _databaseWatcherHealthValidationHealthValidationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, healthValidationName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _healthValidationsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, healthValidationName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherHealthValidationData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherHealthValidationData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherHealthValidationResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -333,41 +384,57 @@ public virtual async Task - /// Tries to get details for this resource from the service. + /// Get a HealthValidation /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}. /// /// - /// Operation Id - /// HealthValidation_Get + /// Operation Id. + /// HealthValidations_Get. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The health validation resource name. /// 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 healthValidationName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); - using var scope = _databaseWatcherHealthValidationHealthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationCollection.GetIfExists"); + using DiagnosticScope scope = _healthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationCollection.GetIfExists"); scope.Start(); try { - var response = _databaseWatcherHealthValidationHealthValidationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, healthValidationName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _healthValidationsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, healthValidationName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherHealthValidationData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherHealthValidationData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherHealthValidationResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -387,6 +454,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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationData.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationData.Serialization.cs index 06940fae91ae..d428981bd119 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationData.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationData.Serialization.cs @@ -10,16 +10,18 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.DatabaseWatcher.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DatabaseWatcher { - public partial class DatabaseWatcherHealthValidationData : IUtf8JsonSerializable, IJsonModel + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + public partial class DatabaseWatcherHealthValidationData : ResourceData, 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(); @@ -31,12 +33,11 @@ void IJsonModel.Write(Utf8JsonWriter writer /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DatabaseWatcherHealthValidationData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Properties)) { @@ -45,87 +46,101 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DatabaseWatcherHealthValidationData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherHealthValidationData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DatabaseWatcherHealthValidationData)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(DatabaseWatcherHealthValidationData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherHealthValidationData(document.RootElement, options); } - internal static DatabaseWatcherHealthValidationData DeserializeDatabaseWatcherHealthValidationData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DatabaseWatcherHealthValidationData DeserializeDatabaseWatcherHealthValidationData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DatabaseWatcherHealthValidationProperties properties = 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(); + DatabaseWatcherHealthValidationProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = DatabaseWatcherHealthValidationProperties.DeserializeDatabaseWatcherHealthValidationProperties(property.Value, options); + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("name"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("type"u8)) { - name = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("systemData"u8)) { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDatabaseWatcherContext.Default); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("properties"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, AzureResourceManagerDatabaseWatcherContext.Default); + properties = DatabaseWatcherHealthValidationProperties.DeserializeDatabaseWatcherHealthValidationProperties(prop.Value, options); 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 DatabaseWatcherHealthValidationData( id, name, - type, + resourceType, systemData, - properties, - serializedAdditionalRawData); + additionalBinaryDataProperties, + properties); } - 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 +150,20 @@ BinaryData IPersistableModel.Write(ModelRea } } - DatabaseWatcherHealthValidationData 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. + DatabaseWatcherHealthValidationData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DatabaseWatcherHealthValidationData)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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherHealthValidationData(document.RootElement, options); } default: @@ -151,6 +171,15 @@ DatabaseWatcherHealthValidationData IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static DatabaseWatcherHealthValidationData FromResponse(Response result) + { + using Response response = result; + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeDatabaseWatcherHealthValidationData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationData.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationData.cs index 8aae4fbefd1d..1d486c4b5f86 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationData.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationData.cs @@ -13,43 +13,11 @@ namespace Azure.ResourceManager.DatabaseWatcher { - /// - /// A class representing the DatabaseWatcherHealthValidation data model. - /// Concrete proxy resource types can be created by aliasing this type using a specific property type. - /// + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. public partial class DatabaseWatcherHealthValidationData : ResourceData { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal DatabaseWatcherHealthValidationData() @@ -57,16 +25,16 @@ internal DatabaseWatcherHealthValidationData() } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// 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. /// The resource-specific properties for this resource. - /// Keeps track of any properties unknown to the library. - internal DatabaseWatcherHealthValidationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, DatabaseWatcherHealthValidationProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + internal DatabaseWatcherHealthValidationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, DatabaseWatcherHealthValidationProperties properties) : base(id, name, resourceType, systemData) { + _additionalBinaryDataProperties = additionalBinaryDataProperties; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; } /// The resource-specific properties for this resource. diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationResource.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationResource.Serialization.cs index 1efe506db8c9..b211df24e178 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationResource.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.DatabaseWatcher { + /// public partial class DatabaseWatcherHealthValidationResource : IJsonModel { - private static DatabaseWatcherHealthValidationData s_dataDeserializationInstance; - private static DatabaseWatcherHealthValidationData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new DatabaseWatcherHealthValidationData(); + + /// 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); - DatabaseWatcherHealthValidationData 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. + DatabaseWatcherHealthValidationData 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, AzureResourceManagerDatabaseWatcherContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. DatabaseWatcherHealthValidationData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDatabaseWatcherContext.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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationResource.cs index 12494a0aee91..0759e5c52936 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationResource.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherHealthValidationResource.cs @@ -6,46 +6,35 @@ #nullable disable using System; -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; namespace Azure.ResourceManager.DatabaseWatcher { /// - /// A Class representing a DatabaseWatcherHealthValidation 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 GetDatabaseWatcherHealthValidationResource method. - /// Otherwise you can get one from its parent resource using the GetDatabaseWatcherHealthValidation method. + /// A class representing a DatabaseWatcherHealthValidation 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 GetDatabaseWatcherHealthValidations method. /// public partial class DatabaseWatcherHealthValidationResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The watcherName. - /// The healthValidationName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string healthValidationName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _databaseWatcherHealthValidationHealthValidationsClientDiagnostics; - private readonly HealthValidationsRestOperations _databaseWatcherHealthValidationHealthValidationsRestClient; + private readonly ClientDiagnostics _healthValidationsClientDiagnostics; + private readonly HealthValidations _healthValidationsRestClient; private readonly DatabaseWatcherHealthValidationData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.DatabaseWatcher/watchers/healthValidations"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DatabaseWatcherHealthValidationResource for mocking. protected DatabaseWatcherHealthValidationResource() { } - /// 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 DatabaseWatcherHealthValidationResource(ArmClient client, DatabaseWatcherHealthValidationData data) : this(client, data.Id) @@ -54,71 +43,93 @@ internal DatabaseWatcherHealthValidationResource(ArmClient client, DatabaseWatch _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 DatabaseWatcherHealthValidationResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _databaseWatcherHealthValidationHealthValidationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string databaseWatcherHealthValidationHealthValidationsApiVersion); - _databaseWatcherHealthValidationHealthValidationsRestClient = new HealthValidationsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, databaseWatcherHealthValidationHealthValidationsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string databaseWatcherHealthValidationApiVersion); + _healthValidationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); + _healthValidationsRestClient = new HealthValidations(_healthValidationsClientDiagnostics, Pipeline, Endpoint, databaseWatcherHealthValidationApiVersion ?? "2025-01-02"); + 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 DatabaseWatcherHealthValidationData 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 watcherName. + /// The healthValidationName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string healthValidationName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}"; + 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 HealthValidation /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}. /// /// - /// Operation Id - /// HealthValidation_Get + /// Operation Id. + /// HealthValidations_Get. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherHealthValidationHealthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationResource.Get"); + using DiagnosticScope scope = _healthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationResource.Get"); scope.Start(); try { - var response = await _databaseWatcherHealthValidationHealthValidationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _healthValidationsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherHealthValidationData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherHealthValidationResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -132,33 +143,41 @@ public virtual async Task> Get /// Get a HealthValidation /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}. /// /// - /// Operation Id - /// HealthValidation_Get + /// Operation Id. + /// HealthValidations_Get. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherHealthValidationHealthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationResource.Get"); + using DiagnosticScope scope = _healthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationResource.Get"); scope.Start(); try { - var response = _databaseWatcherHealthValidationHealthValidationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _healthValidationsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherHealthValidationData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherHealthValidationResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -172,20 +191,20 @@ public virtual Response Get(Cancellatio /// Starts health validation for a watcher. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}/startValidation + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}/startValidation. /// /// - /// Operation Id - /// HealthValidations_StartValidation + /// Operation Id. + /// HealthValidations_StartValidation. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -193,14 +212,27 @@ public virtual Response Get(Cancellatio /// The cancellation token to use. public virtual async Task> StartValidationAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherHealthValidationHealthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationResource.StartValidation"); + using DiagnosticScope scope = _healthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationResource.StartValidation"); scope.Start(); try { - var response = await _databaseWatcherHealthValidationHealthValidationsRestClient.StartValidationAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new DatabaseWatcherArmOperation(new DatabaseWatcherHealthValidationOperationSource(Client), _databaseWatcherHealthValidationHealthValidationsClientDiagnostics, Pipeline, _databaseWatcherHealthValidationHealthValidationsRestClient.CreateStartValidationRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _healthValidationsRestClient.CreateStartValidationRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation( + new DatabaseWatcherHealthValidationOperationSource(Client), + _healthValidationsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -214,20 +246,20 @@ public virtual async Task> /// Starts health validation for a watcher. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}/startValidation + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}/startValidation. /// /// - /// Operation Id - /// HealthValidations_StartValidation + /// Operation Id. + /// HealthValidations_StartValidation. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -235,14 +267,27 @@ public virtual async Task> /// The cancellation token to use. public virtual ArmOperation StartValidation(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherHealthValidationHealthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationResource.StartValidation"); + using DiagnosticScope scope = _healthValidationsClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationResource.StartValidation"); scope.Start(); try { - var response = _databaseWatcherHealthValidationHealthValidationsRestClient.StartValidation(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var operation = new DatabaseWatcherArmOperation(new DatabaseWatcherHealthValidationOperationSource(Client), _databaseWatcherHealthValidationHealthValidationsClientDiagnostics, Pipeline, _databaseWatcherHealthValidationHealthValidationsRestClient.CreateStartValidationRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _healthValidationsRestClient.CreateStartValidationRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation( + new DatabaseWatcherHealthValidationOperationSource(Client), + _healthValidationsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherResource.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherResource.Serialization.cs index 53cd386afc1d..08bcf8b5418b 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherResource.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.DatabaseWatcher { + /// public partial class DatabaseWatcherResource : IJsonModel { - private static DatabaseWatcherData s_dataDeserializationInstance; - private static DatabaseWatcherData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new DatabaseWatcherData(); + + /// 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); - DatabaseWatcherData 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. + DatabaseWatcherData 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, AzureResourceManagerDatabaseWatcherContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. DatabaseWatcherData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDatabaseWatcherContext.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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherResource.cs index 099931e03d1a..84dbd427f324 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherResource.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherResource.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.DatabaseWatcher.Models; using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.DatabaseWatcher { /// - /// A Class representing a DatabaseWatcher 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 GetDatabaseWatcherResource method. - /// Otherwise you can get one from its parent resource using the GetDatabaseWatcher method. + /// A class representing a DatabaseWatcher 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 GetDatabaseWatchers method. /// public partial class DatabaseWatcherResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The watcherName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _databaseWatcherWatchersClientDiagnostics; - private readonly WatchersRestOperations _databaseWatcherWatchersRestClient; + private readonly ClientDiagnostics _watchersClientDiagnostics; + private readonly Watchers _watchersRestClient; private readonly DatabaseWatcherData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.DatabaseWatcher/watchers"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DatabaseWatcherResource for mocking. protected DatabaseWatcherResource() { } - /// 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 DatabaseWatcherResource(ArmClient client, DatabaseWatcherData data) : this(client, data.Id) @@ -56,347 +46,92 @@ internal DatabaseWatcherResource(ArmClient client, DatabaseWatcherData data) : t _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 DatabaseWatcherResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _databaseWatcherWatchersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string databaseWatcherWatchersApiVersion); - _databaseWatcherWatchersRestClient = new WatchersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, databaseWatcherWatchersApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string databaseWatcherApiVersion); + _watchersClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); + _watchersRestClient = new Watchers(_watchersClientDiagnostics, Pipeline, Endpoint, databaseWatcherApiVersion ?? "2025-01-02"); + 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 DatabaseWatcherData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } - internal static void ValidateResourceId(ResourceIdentifier id) - { - if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); - } - - /// Gets a collection of DatabaseWatcherAlertRuleResources in the DatabaseWatcher. - /// An object representing collection of DatabaseWatcherAlertRuleResources and their operations over a DatabaseWatcherAlertRuleResource. - public virtual DatabaseWatcherAlertRuleCollection GetDatabaseWatcherAlertRules() - { - return GetCachedClient(client => new DatabaseWatcherAlertRuleCollection(client, Id)); - } - - /// - /// Get a AlertRuleResource - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} - /// - /// - /// Operation Id - /// AlertRuleResource_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// - /// The alert rule proxy resource name. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetDatabaseWatcherAlertRuleAsync(string alertRuleResourceName, CancellationToken cancellationToken = default) - { - return await GetDatabaseWatcherAlertRules().GetAsync(alertRuleResourceName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get a AlertRuleResource - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} - /// - /// - /// Operation Id - /// AlertRuleResource_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// - /// The alert rule proxy resource name. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetDatabaseWatcherAlertRule(string alertRuleResourceName, CancellationToken cancellationToken = default) - { - return GetDatabaseWatcherAlertRules().Get(alertRuleResourceName, cancellationToken); - } - - /// Gets a collection of DatabaseWatcherHealthValidationResources in the DatabaseWatcher. - /// An object representing collection of DatabaseWatcherHealthValidationResources and their operations over a DatabaseWatcherHealthValidationResource. - public virtual DatabaseWatcherHealthValidationCollection GetDatabaseWatcherHealthValidations() - { - return GetCachedClient(client => new DatabaseWatcherHealthValidationCollection(client, Id)); - } - - /// - /// Get a HealthValidation - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName} - /// - /// - /// Operation Id - /// HealthValidation_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// - /// The health validation resource name. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetDatabaseWatcherHealthValidationAsync(string healthValidationName, CancellationToken cancellationToken = default) - { - return await GetDatabaseWatcherHealthValidations().GetAsync(healthValidationName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get a HealthValidation - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName} - /// - /// - /// Operation Id - /// HealthValidation_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// - /// The health validation resource name. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetDatabaseWatcherHealthValidation(string healthValidationName, CancellationToken cancellationToken = default) - { - return GetDatabaseWatcherHealthValidations().Get(healthValidationName, cancellationToken); - } - - /// Gets a collection of DatabaseWatcherTargetResources in the DatabaseWatcher. - /// An object representing collection of DatabaseWatcherTargetResources and their operations over a DatabaseWatcherTargetResource. - public virtual DatabaseWatcherTargetCollection GetDatabaseWatcherTargets() - { - return GetCachedClient(client => new DatabaseWatcherTargetCollection(client, Id)); - } - - /// - /// Get a Target - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} - /// - /// - /// Operation Id - /// Target_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// - /// The target resource name. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetDatabaseWatcherTargetAsync(string targetName, CancellationToken cancellationToken = default) - { - return await GetDatabaseWatcherTargets().GetAsync(targetName, cancellationToken).ConfigureAwait(false); - } - - /// - /// Get a Target - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} - /// - /// - /// Operation Id - /// Target_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// - /// The target resource name. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetDatabaseWatcherTarget(string targetName, CancellationToken cancellationToken = default) - { - return GetDatabaseWatcherTargets().Get(targetName, cancellationToken); - } - - /// Gets a collection of DatabaseWatcherSharedPrivateLinkResources in the DatabaseWatcher. - /// An object representing collection of DatabaseWatcherSharedPrivateLinkResources and their operations over a DatabaseWatcherSharedPrivateLinkResource. - public virtual DatabaseWatcherSharedPrivateLinkResourceCollection GetDatabaseWatcherSharedPrivateLinkResources() - { - return GetCachedClient(client => new DatabaseWatcherSharedPrivateLinkResourceCollection(client, Id)); - } - - /// - /// Get a SharedPrivateLinkResource - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} - /// - /// - /// Operation Id - /// SharedPrivateLinkResource_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// - /// The Shared Private Link resource name. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual async Task> GetDatabaseWatcherSharedPrivateLinkResourceAsync(string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The watcherName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName) { - return await GetDatabaseWatcherSharedPrivateLinkResources().GetAsync(sharedPrivateLinkResourceName, cancellationToken).ConfigureAwait(false); + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}"; + return new ResourceIdentifier(resourceId); } - /// - /// Get a SharedPrivateLinkResource - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} - /// - /// - /// Operation Id - /// SharedPrivateLinkResource_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// - /// The Shared Private Link resource name. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - [ForwardsClientCalls] - public virtual Response GetDatabaseWatcherSharedPrivateLinkResource(string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) + /// + [Conditional("DEBUG")] + internal static void ValidateResourceId(ResourceIdentifier id) { - return GetDatabaseWatcherSharedPrivateLinkResources().Get(sharedPrivateLinkResourceName, cancellationToken); + if (id.ResourceType != ResourceType) + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// /// Get a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Operation Id - /// Watcher_Get + /// Operation Id. + /// Watchers_Get. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Get"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Get"); scope.Start(); try { - var response = await _databaseWatcherWatchersRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -410,33 +145,41 @@ public virtual async Task> GetAsync(Cancellati /// Get a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Operation Id - /// Watcher_Get + /// Operation Id. + /// Watchers_Get. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Get"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Get"); scope.Start(); try { - var response = _databaseWatcherWatchersRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -447,38 +190,55 @@ public virtual Response Get(CancellationToken cancellat } /// - /// Delete a Watcher + /// Update a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Operation Id - /// Watcher_Delete + /// Operation Id. + /// Watchers_Update. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// 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 resource properties to be updated. /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, DatabaseWatcherPatch patch, CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Update"); scope.Start(); try { - var response = await _databaseWatcherWatchersRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new DatabaseWatcherArmOperation(_databaseWatcherWatchersClientDiagnostics, Pipeline, _databaseWatcherWatchersRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, DatabaseWatcherPatch.ToRequestContent(patch), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation( + new DatabaseWatcherOperationSource(Client), + _watchersClientDiagnostics, + 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) @@ -489,38 +249,55 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell } /// - /// Delete a Watcher + /// Update a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Operation Id - /// Watcher_Delete + /// Operation Id. + /// Watchers_Update. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// 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 resource properties to be updated. /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, DatabaseWatcherPatch patch, CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Update"); scope.Start(); try { - var response = _databaseWatcherWatchersRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var operation = new DatabaseWatcherArmOperation(_databaseWatcherWatchersClientDiagnostics, Pipeline, _databaseWatcherWatchersRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, DatabaseWatcherPatch.ToRequestContent(patch), context); + Response response = Pipeline.ProcessMessage(message, context); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation( + new DatabaseWatcherOperationSource(Client), + _watchersClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); + { + operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -531,42 +308,45 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel } /// - /// Update a Watcher + /// Delete a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Operation Id - /// Watcher_Update + /// Operation Id. + /// Watchers_Delete. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// 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 resource properties to be updated. /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, DatabaseWatcherPatch patch, CancellationToken cancellationToken = default) + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Update"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Delete"); scope.Start(); try { - var response = await _databaseWatcherWatchersRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); - var operation = new DatabaseWatcherArmOperation(new DatabaseWatcherOperationSource(Client), _databaseWatcherWatchersClientDiagnostics, Pipeline, _databaseWatcherWatchersRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(_watchersClientDiagnostics, 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) @@ -577,42 +357,45 @@ public virtual async Task> UpdateAsync(Wai } /// - /// Update a Watcher + /// Delete a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Operation Id - /// Watcher_Update + /// Operation Id. + /// Watchers_Delete. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// 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 resource properties to be updated. /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, DatabaseWatcherPatch patch, CancellationToken cancellationToken = default) + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Update"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Delete"); scope.Start(); try { - var response = _databaseWatcherWatchersRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); - var operation = new DatabaseWatcherArmOperation(new DatabaseWatcherOperationSource(Client), _databaseWatcherWatchersClientDiagnostics, Pipeline, _databaseWatcherWatchersRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(_watchersClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); + { + operation.WaitForCompletionResponse(cancellationToken); + } return operation; } catch (Exception e) @@ -626,20 +409,20 @@ public virtual ArmOperation Update(WaitUntil waitUntil, /// The action to start monitoring all targets configured for a database watcher. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/start + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/start. /// /// - /// Operation Id - /// Watchers_Start + /// Operation Id. + /// Watchers_Start. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -647,14 +430,21 @@ public virtual ArmOperation Update(WaitUntil waitUntil, /// The cancellation token to use. public virtual async Task StartAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Start"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Start"); scope.Start(); try { - var response = await _databaseWatcherWatchersRestClient.StartAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new DatabaseWatcherArmOperation(_databaseWatcherWatchersClientDiagnostics, Pipeline, _databaseWatcherWatchersRestClient.CreateStartRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateStartRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(_watchersClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -668,20 +458,20 @@ public virtual async Task StartAsync(WaitUntil waitUntil, Cancella /// The action to start monitoring all targets configured for a database watcher. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/start + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/start. /// /// - /// Operation Id - /// Watchers_Start + /// Operation Id. + /// Watchers_Start. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -689,14 +479,21 @@ public virtual async Task StartAsync(WaitUntil waitUntil, Cancella /// The cancellation token to use. public virtual ArmOperation Start(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Start"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Start"); scope.Start(); try { - var response = _databaseWatcherWatchersRestClient.Start(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var operation = new DatabaseWatcherArmOperation(_databaseWatcherWatchersClientDiagnostics, Pipeline, _databaseWatcherWatchersRestClient.CreateStartRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateStartRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(_watchersClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletionResponse(cancellationToken); + } return operation; } catch (Exception e) @@ -710,20 +507,20 @@ public virtual ArmOperation Start(WaitUntil waitUntil, CancellationToken cancell /// The action to stop monitoring all targets configured for a database watcher. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/stop + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/stop. /// /// - /// Operation Id - /// Watchers_Stop + /// Operation Id. + /// Watchers_Stop. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -731,14 +528,21 @@ public virtual ArmOperation Start(WaitUntil waitUntil, CancellationToken cancell /// The cancellation token to use. public virtual async Task StopAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Stop"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Stop"); scope.Start(); try { - var response = await _databaseWatcherWatchersRestClient.StopAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new DatabaseWatcherArmOperation(_databaseWatcherWatchersClientDiagnostics, Pipeline, _databaseWatcherWatchersRestClient.CreateStopRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateStopRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(_watchersClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -752,20 +556,20 @@ public virtual async Task StopAsync(WaitUntil waitUntil, Cancellat /// The action to stop monitoring all targets configured for a database watcher. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/stop + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/stop. /// /// - /// Operation Id - /// Watchers_Stop + /// Operation Id. + /// Watchers_Stop. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -773,14 +577,21 @@ public virtual async Task StopAsync(WaitUntil waitUntil, Cancellat /// The cancellation token to use. public virtual ArmOperation Stop(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Stop"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.Stop"); scope.Start(); try { - var response = _databaseWatcherWatchersRestClient.Stop(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var operation = new DatabaseWatcherArmOperation(_databaseWatcherWatchersClientDiagnostics, Pipeline, _databaseWatcherWatchersRestClient.CreateStopRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateStopRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(_watchersClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletionResponse(cancellationToken); + } return operation; } catch (Exception e) @@ -790,27 +601,7 @@ public virtual ArmOperation Stop(WaitUntil waitUntil, CancellationToken cancella } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -820,28 +611,34 @@ public virtual async Task> AddTagAsync(string Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.AddTag"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.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 _databaseWatcherWatchersRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new DatabaseWatcherResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherData.FromResponse(result), result); + return Response.FromValue(new DatabaseWatcherResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new DatabaseWatcherPatch(); - foreach (var tag in current.Tags) + DatabaseWatcherData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + DatabaseWatcherPatch patch = new DatabaseWatcherPatch(); + 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).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -852,27 +649,7 @@ public virtual async Task> AddTagAsync(string } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -882,28 +659,34 @@ public virtual Response AddTag(string key, string value Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.AddTag"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.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 = _databaseWatcherWatchersRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new DatabaseWatcherResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherData.FromResponse(result), result); + return Response.FromValue(new DatabaseWatcherResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new DatabaseWatcherPatch(); - foreach (var tag in current.Tags) + DatabaseWatcherData current = Get(cancellationToken: cancellationToken).Value.Data; + DatabaseWatcherPatch patch = new DatabaseWatcherPatch(); + 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); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -914,53 +697,39 @@ public virtual Response AddTag(string key, string value } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// 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 = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.SetTags"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.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 _databaseWatcherWatchersRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new DatabaseWatcherResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherData.FromResponse(result), result); + return Response.FromValue(new DatabaseWatcherResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new DatabaseWatcherPatch(); + DatabaseWatcherData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + DatabaseWatcherPatch patch = new DatabaseWatcherPatch(); patch.Tags.ReplaceWith(tags); - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -971,53 +740,39 @@ public virtual async Task> SetTagsAsync(IDicti } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// 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 = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.SetTags"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.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 = _databaseWatcherWatchersRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new DatabaseWatcherResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherData.FromResponse(result), result); + return Response.FromValue(new DatabaseWatcherResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new DatabaseWatcherPatch(); + DatabaseWatcherData current = Get(cancellationToken: cancellationToken).Value.Data; + DatabaseWatcherPatch patch = new DatabaseWatcherPatch(); patch.Tags.ReplaceWith(tags); - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -1028,27 +783,7 @@ public virtual Response SetTags(IDictionary - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -1056,28 +791,34 @@ public virtual async Task> RemoveTagAsync(stri { Argument.AssertNotNull(key, nameof(key)); - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.RemoveTag"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.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 _databaseWatcherWatchersRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new DatabaseWatcherResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherData.FromResponse(result), result); + return Response.FromValue(new DatabaseWatcherResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new DatabaseWatcherPatch(); - foreach (var tag in current.Tags) + DatabaseWatcherData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + DatabaseWatcherPatch patch = new DatabaseWatcherPatch(); + 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).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -1088,27 +829,7 @@ public virtual async Task> RemoveTagAsync(stri } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -1116,28 +837,34 @@ public virtual Response RemoveTag(string key, Cancellat { Argument.AssertNotNull(key, nameof(key)); - using var scope = _databaseWatcherWatchersClientDiagnostics.CreateScope("DatabaseWatcherResource.RemoveTag"); + using DiagnosticScope scope = _watchersClientDiagnostics.CreateScope("DatabaseWatcherResource.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 = _databaseWatcherWatchersRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new DatabaseWatcherResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _watchersRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherData.FromResponse(result), result); + return Response.FromValue(new DatabaseWatcherResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new DatabaseWatcherPatch(); - foreach (var tag in current.Tags) + DatabaseWatcherData current = Get(cancellationToken: cancellationToken).Value.Data; + DatabaseWatcherPatch patch = new DatabaseWatcherPatch(); + 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); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -1147,5 +874,137 @@ public virtual Response RemoveTag(string key, Cancellat throw; } } + + /// Gets a collection of DatabaseWatcherAlertRules in the . + /// An object representing collection of DatabaseWatcherAlertRules and their operations over a DatabaseWatcherAlertRuleResource. + public virtual DatabaseWatcherAlertRuleCollection GetDatabaseWatcherAlertRules() + { + return GetCachedClient(client => new DatabaseWatcherAlertRuleCollection(client, Id)); + } + + /// Get a AlertRuleResource. + /// The alert rule proxy resource name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDatabaseWatcherAlertRuleAsync(string alertRuleResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); + + return await GetDatabaseWatcherAlertRules().GetAsync(alertRuleResourceName, cancellationToken).ConfigureAwait(false); + } + + /// Get a AlertRuleResource. + /// The alert rule proxy resource name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDatabaseWatcherAlertRule(string alertRuleResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); + + return GetDatabaseWatcherAlertRules().Get(alertRuleResourceName, cancellationToken); + } + + /// Gets a collection of DatabaseWatcherHealthValidations in the . + /// An object representing collection of DatabaseWatcherHealthValidations and their operations over a DatabaseWatcherHealthValidationResource. + public virtual DatabaseWatcherHealthValidationCollection GetDatabaseWatcherHealthValidations() + { + return GetCachedClient(client => new DatabaseWatcherHealthValidationCollection(client, Id)); + } + + /// Get a HealthValidation. + /// The health validation resource name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDatabaseWatcherHealthValidationAsync(string healthValidationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); + + return await GetDatabaseWatcherHealthValidations().GetAsync(healthValidationName, cancellationToken).ConfigureAwait(false); + } + + /// Get a HealthValidation. + /// The health validation resource name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDatabaseWatcherHealthValidation(string healthValidationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); + + return GetDatabaseWatcherHealthValidations().Get(healthValidationName, cancellationToken); + } + + /// Gets a collection of DatabaseWatcherTargets in the . + /// An object representing collection of DatabaseWatcherTargets and their operations over a DatabaseWatcherTargetResource. + public virtual DatabaseWatcherTargetCollection GetDatabaseWatcherTargets() + { + return GetCachedClient(client => new DatabaseWatcherTargetCollection(client, Id)); + } + + /// Get a Target. + /// The target resource name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDatabaseWatcherTargetAsync(string targetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); + + return await GetDatabaseWatcherTargets().GetAsync(targetName, cancellationToken).ConfigureAwait(false); + } + + /// Get a Target. + /// The target resource name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDatabaseWatcherTarget(string targetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); + + return GetDatabaseWatcherTargets().Get(targetName, cancellationToken); + } + + /// Gets a collection of DatabaseWatcherSharedPrivateLinkResources in the . + /// An object representing collection of DatabaseWatcherSharedPrivateLinkResources and their operations over a DatabaseWatcherSharedPrivateLinkResource. + public virtual DatabaseWatcherSharedPrivateLinkResourceCollection GetDatabaseWatcherSharedPrivateLinkResources() + { + return GetCachedClient(client => new DatabaseWatcherSharedPrivateLinkResourceCollection(client, Id)); + } + + /// Get a SharedPrivateLinkResource. + /// The Shared Private Link resource name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetDatabaseWatcherSharedPrivateLinkResourceAsync(string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); + + return await GetDatabaseWatcherSharedPrivateLinkResources().GetAsync(sharedPrivateLinkResourceName, cancellationToken).ConfigureAwait(false); + } + + /// Get a SharedPrivateLinkResource. + /// The Shared Private Link resource name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetDatabaseWatcherSharedPrivateLinkResource(string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); + + return GetDatabaseWatcherSharedPrivateLinkResources().Get(sharedPrivateLinkResourceName, cancellationToken); + } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResource.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResource.Serialization.cs index eb54c734db15..2b2ed93d2efb 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResource.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.DatabaseWatcher { + /// public partial class DatabaseWatcherSharedPrivateLinkResource : IJsonModel { - private static DatabaseWatcherSharedPrivateLinkResourceData s_dataDeserializationInstance; - private static DatabaseWatcherSharedPrivateLinkResourceData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new DatabaseWatcherSharedPrivateLinkResourceData(); + + /// 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); - DatabaseWatcherSharedPrivateLinkResourceData 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. + DatabaseWatcherSharedPrivateLinkResourceData 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, AzureResourceManagerDatabaseWatcherContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. DatabaseWatcherSharedPrivateLinkResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDatabaseWatcherContext.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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResource.cs index a612dc5c6e80..0ad714e9ee07 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResource.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResource.cs @@ -6,46 +6,35 @@ #nullable disable using System; -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; namespace Azure.ResourceManager.DatabaseWatcher { /// - /// A Class representing a DatabaseWatcherSharedPrivateLinkResource 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 GetDatabaseWatcherSharedPrivateLinkResource method. - /// Otherwise you can get one from its parent resource using the GetDatabaseWatcherSharedPrivateLinkResource method. + /// A class representing a DatabaseWatcherSharedPrivateLinkResource 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 GetDatabaseWatcherSharedPrivateLinkResources method. /// public partial class DatabaseWatcherSharedPrivateLinkResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The watcherName. - /// The sharedPrivateLinkResourceName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics; - private readonly SharedPrivateLinkResourcesRestOperations _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient; + private readonly ClientDiagnostics _sharedPrivateLinkResourcesClientDiagnostics; + private readonly SharedPrivateLinkResources _sharedPrivateLinkResourcesRestClient; private readonly DatabaseWatcherSharedPrivateLinkResourceData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.DatabaseWatcher/watchers/sharedPrivateLinkResources"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DatabaseWatcherSharedPrivateLinkResource for mocking. protected DatabaseWatcherSharedPrivateLinkResource() { } - /// 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 DatabaseWatcherSharedPrivateLinkResource(ArmClient client, DatabaseWatcherSharedPrivateLinkResourceData data) : this(client, data.Id) @@ -54,71 +43,93 @@ internal DatabaseWatcherSharedPrivateLinkResource(ArmClient client, DatabaseWatc _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 DatabaseWatcherSharedPrivateLinkResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesApiVersion); - _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient = new SharedPrivateLinkResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string databaseWatcherSharedPrivateLinkResourceApiVersion); + _sharedPrivateLinkResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); + _sharedPrivateLinkResourcesRestClient = new SharedPrivateLinkResources(_sharedPrivateLinkResourcesClientDiagnostics, Pipeline, Endpoint, databaseWatcherSharedPrivateLinkResourceApiVersion ?? "2025-01-02"); + 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 DatabaseWatcherSharedPrivateLinkResourceData 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 watcherName. + /// The sharedPrivateLinkResourceName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}"; + 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 SharedPrivateLinkResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}. /// /// - /// Operation Id - /// SharedPrivateLinkResource_Get + /// Operation Id. + /// SharedPrivateLinkResources_Get. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResource.Get"); + using DiagnosticScope scope = _sharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResource.Get"); scope.Start(); try { - var response = await _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sharedPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherSharedPrivateLinkResourceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherSharedPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -132,33 +143,41 @@ public virtual async Task> Ge /// Get a SharedPrivateLinkResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}. /// /// - /// Operation Id - /// SharedPrivateLinkResource_Get + /// Operation Id. + /// SharedPrivateLinkResources_Get. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResource.Get"); + using DiagnosticScope scope = _sharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResource.Get"); scope.Start(); try { - var response = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sharedPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherSharedPrivateLinkResourceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherSharedPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -172,20 +191,20 @@ public virtual Response Get(Cancellati /// Delete a SharedPrivateLinkResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}. /// /// - /// Operation Id - /// SharedPrivateLinkResource_Delete + /// Operation Id. + /// SharedPrivateLinkResources_Delete. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -193,14 +212,21 @@ public virtual Response Get(Cancellati /// The cancellation token to use. public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResource.Delete"); + using DiagnosticScope scope = _sharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResource.Delete"); scope.Start(); try { - var response = await _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new DatabaseWatcherArmOperation(_databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics, Pipeline, _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sharedPrivateLinkResourcesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(_sharedPrivateLinkResourcesClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -214,20 +240,20 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// Delete a SharedPrivateLinkResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}. /// /// - /// Operation Id - /// SharedPrivateLinkResource_Delete + /// Operation Id. + /// SharedPrivateLinkResources_Delete. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -235,14 +261,21 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// The cancellation token to use. public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResource.Delete"); + using DiagnosticScope scope = _sharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResource.Delete"); scope.Start(); try { - var response = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var operation = new DatabaseWatcherArmOperation(_databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics, Pipeline, _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sharedPrivateLinkResourcesRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(_sharedPrivateLinkResourcesClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletionResponse(cancellationToken); + } return operation; } catch (Exception e) @@ -256,20 +289,20 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// Create a SharedPrivateLinkResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}. /// /// - /// Operation Id - /// SharedPrivateLinkResource_Create + /// Operation Id. + /// SharedPrivateLinkResources_Create. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -281,14 +314,27 @@ public virtual async Task { Argument.AssertNotNull(data, nameof(data)); - using var scope = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResource.Update"); + using DiagnosticScope scope = _sharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResource.Update"); scope.Start(); try { - var response = await _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); - var operation = new DatabaseWatcherArmOperation(new DatabaseWatcherSharedPrivateLinkResourceOperationSource(Client), _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics, Pipeline, _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sharedPrivateLinkResourcesRestClient.CreateCreateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, DatabaseWatcherSharedPrivateLinkResourceData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation( + new DatabaseWatcherSharedPrivateLinkResourceOperationSource(Client), + _sharedPrivateLinkResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -302,20 +348,20 @@ public virtual async Task /// Create a SharedPrivateLinkResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}. /// /// - /// Operation Id - /// SharedPrivateLinkResource_Create + /// Operation Id. + /// SharedPrivateLinkResources_Create. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -327,14 +373,27 @@ public virtual ArmOperation Update(Wai { Argument.AssertNotNull(data, nameof(data)); - using var scope = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResource.Update"); + using DiagnosticScope scope = _sharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResource.Update"); scope.Start(); try { - var response = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); - var operation = new DatabaseWatcherArmOperation(new DatabaseWatcherSharedPrivateLinkResourceOperationSource(Client), _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics, Pipeline, _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sharedPrivateLinkResourcesRestClient.CreateCreateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, DatabaseWatcherSharedPrivateLinkResourceData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation( + new DatabaseWatcherSharedPrivateLinkResourceOperationSource(Client), + _sharedPrivateLinkResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResourceCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResourceCollection.cs index 9ff1f3914249..5f2947433cc7 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResourceCollection.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResourceCollection.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; namespace Azure.ResourceManager.DatabaseWatcher { @@ -24,51 +25,49 @@ namespace Azure.ResourceManager.DatabaseWatcher /// public partial class DatabaseWatcherSharedPrivateLinkResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics; - private readonly SharedPrivateLinkResourcesRestOperations _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient; + private readonly ClientDiagnostics _sharedPrivateLinkResourcesClientDiagnostics; + private readonly SharedPrivateLinkResources _sharedPrivateLinkResourcesRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DatabaseWatcherSharedPrivateLinkResourceCollection for mocking. protected DatabaseWatcherSharedPrivateLinkResourceCollection() { } - /// 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 DatabaseWatcherSharedPrivateLinkResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", DatabaseWatcherSharedPrivateLinkResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(DatabaseWatcherSharedPrivateLinkResource.ResourceType, out string databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesApiVersion); - _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient = new SharedPrivateLinkResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(DatabaseWatcherSharedPrivateLinkResource.ResourceType, out string databaseWatcherSharedPrivateLinkResourceApiVersion); + _sharedPrivateLinkResourcesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", DatabaseWatcherSharedPrivateLinkResource.ResourceType.Namespace, Diagnostics); + _sharedPrivateLinkResourcesRestClient = new SharedPrivateLinkResources(_sharedPrivateLinkResourcesClientDiagnostics, Pipeline, Endpoint, databaseWatcherSharedPrivateLinkResourceApiVersion ?? "2025-01-02"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != DatabaseWatcherResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, DatabaseWatcherResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, DatabaseWatcherResource.ResourceType), id); + } } /// /// Create a SharedPrivateLinkResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} - /// - /// - /// Operation Id - /// SharedPrivateLinkResource_Create + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// SharedPrivateLinkResources_Create. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -76,21 +75,34 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// The Shared Private Link resource name. /// Resource create parameters. /// 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 sharedPrivateLinkResourceName, DatabaseWatcherSharedPrivateLinkResourceData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.CreateOrUpdate"); + using DiagnosticScope scope = _sharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, data, cancellationToken).ConfigureAwait(false); - var operation = new DatabaseWatcherArmOperation(new DatabaseWatcherSharedPrivateLinkResourceOperationSource(Client), _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics, Pipeline, _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sharedPrivateLinkResourcesRestClient.CreateCreateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, DatabaseWatcherSharedPrivateLinkResourceData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation( + new DatabaseWatcherSharedPrivateLinkResourceOperationSource(Client), + _sharedPrivateLinkResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -104,20 +116,16 @@ public virtual async Task /// Create a SharedPrivateLinkResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}. /// /// - /// Operation Id - /// SharedPrivateLinkResource_Create + /// Operation Id. + /// SharedPrivateLinkResources_Create. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -125,21 +133,34 @@ public virtual async Task /// The Shared Private Link resource name. /// Resource create parameters. /// 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 sharedPrivateLinkResourceName, DatabaseWatcherSharedPrivateLinkResourceData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.CreateOrUpdate"); + using DiagnosticScope scope = _sharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.CreateOrUpdate"); scope.Start(); try { - var response = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, data, cancellationToken); - var operation = new DatabaseWatcherArmOperation(new DatabaseWatcherSharedPrivateLinkResourceOperationSource(Client), _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics, Pipeline, _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sharedPrivateLinkResourcesRestClient.CreateCreateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, DatabaseWatcherSharedPrivateLinkResourceData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation( + new DatabaseWatcherSharedPrivateLinkResourceOperationSource(Client), + _sharedPrivateLinkResourcesClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -153,38 +174,42 @@ public virtual ArmOperation CreateOrUp /// Get a SharedPrivateLinkResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} - /// - /// - /// Operation Id - /// SharedPrivateLinkResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// SharedPrivateLinkResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The Shared Private Link resource name. /// 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 sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); - using var scope = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.Get"); + using DiagnosticScope scope = _sharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.Get"); scope.Start(); try { - var response = await _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sharedPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherSharedPrivateLinkResourceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherSharedPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -198,38 +223,42 @@ public virtual async Task> Ge /// Get a SharedPrivateLinkResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} - /// - /// - /// Operation Id - /// SharedPrivateLinkResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// SharedPrivateLinkResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The Shared Private Link resource name. /// 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 sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); - using var scope = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.Get"); + using DiagnosticScope scope = _sharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.Get"); scope.Start(); try { - var response = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sharedPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherSharedPrivateLinkResourceData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherSharedPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -243,50 +272,44 @@ public virtual Response Get(string sha /// List SharedPrivateLinkResource resources by Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources. /// /// - /// Operation Id - /// SharedPrivateLinkResource_ListByWatcher + /// Operation Id. + /// SharedPrivateLinkResources_ListByWatcher. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// 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) => _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.CreateListByWatcherRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.CreateListByWatcherNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DatabaseWatcherSharedPrivateLinkResource(Client, DatabaseWatcherSharedPrivateLinkResourceData.DeserializeDatabaseWatcherSharedPrivateLinkResourceData(e)), _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics, Pipeline, "DatabaseWatcherSharedPrivateLinkResourceCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new SharedPrivateLinkResourcesGetByWatcherAsyncCollectionResultOfT(_sharedPrivateLinkResourcesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new DatabaseWatcherSharedPrivateLinkResource(Client, data)); } /// /// List SharedPrivateLinkResource resources by Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources - /// - /// - /// Operation Id - /// SharedPrivateLinkResource_ListByWatcher + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// SharedPrivateLinkResources_ListByWatcher. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -294,45 +317,61 @@ public virtual AsyncPageable GetAllAsy /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.CreateListByWatcherRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.CreateListByWatcherNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DatabaseWatcherSharedPrivateLinkResource(Client, DatabaseWatcherSharedPrivateLinkResourceData.DeserializeDatabaseWatcherSharedPrivateLinkResourceData(e)), _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics, Pipeline, "DatabaseWatcherSharedPrivateLinkResourceCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new SharedPrivateLinkResourcesGetByWatcherCollectionResultOfT(_sharedPrivateLinkResourcesRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new DatabaseWatcherSharedPrivateLinkResource(Client, data)); } /// - /// Checks to see if the resource exists in azure. + /// Get a SharedPrivateLinkResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}. /// /// - /// Operation Id - /// SharedPrivateLinkResource_Get + /// Operation Id. + /// SharedPrivateLinkResources_Get. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The Shared Private Link resource name. /// 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 sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); - using var scope = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.Exists"); + using DiagnosticScope scope = _sharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.Exists"); scope.Start(); try { - var response = await _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sharedPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherSharedPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherSharedPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -343,39 +382,53 @@ public virtual async Task> ExistsAsync(string sharedPrivateLinkRe } /// - /// Checks to see if the resource exists in azure. + /// Get a SharedPrivateLinkResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} - /// - /// - /// Operation Id - /// SharedPrivateLinkResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// SharedPrivateLinkResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The Shared Private Link resource name. /// 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 sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); - using var scope = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.Exists"); + using DiagnosticScope scope = _sharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.Exists"); scope.Start(); try { - var response = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sharedPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherSharedPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherSharedPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -386,41 +439,57 @@ public virtual Response Exists(string sharedPrivateLinkResourceName, Cance } /// - /// Tries to get details for this resource from the service. + /// Get a SharedPrivateLinkResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} - /// - /// - /// Operation Id - /// SharedPrivateLinkResource_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// SharedPrivateLinkResources_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The Shared Private Link resource name. /// 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 sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); - using var scope = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.GetIfExists"); + using DiagnosticScope scope = _sharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.GetIfExists"); scope.Start(); try { - var response = await _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sharedPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherSharedPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherSharedPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherSharedPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -431,41 +500,57 @@ public virtual async Task - /// Tries to get details for this resource from the service. + /// Get a SharedPrivateLinkResource /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}. /// /// - /// Operation Id - /// SharedPrivateLinkResource_Get + /// Operation Id. + /// SharedPrivateLinkResources_Get. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The Shared Private Link resource name. /// 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 sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); - using var scope = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.GetIfExists"); + using DiagnosticScope scope = _sharedPrivateLinkResourcesClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.GetIfExists"); scope.Start(); try { - var response = _databaseWatcherSharedPrivateLinkResourceSharedPrivateLinkResourcesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _sharedPrivateLinkResourcesRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherSharedPrivateLinkResourceData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherSharedPrivateLinkResourceData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherSharedPrivateLinkResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -485,6 +570,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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResourceData.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResourceData.Serialization.cs index 8c15a550e474..041662bbd597 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResourceData.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResourceData.Serialization.cs @@ -10,16 +10,18 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.DatabaseWatcher.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DatabaseWatcher { - public partial class DatabaseWatcherSharedPrivateLinkResourceData : IUtf8JsonSerializable, IJsonModel + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + public partial class DatabaseWatcherSharedPrivateLinkResourceData : ResourceData, 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(); @@ -31,12 +33,11 @@ void IJsonModel.Write(Utf8JsonWrit /// 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(DatabaseWatcherSharedPrivateLinkResourceData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Properties)) { @@ -45,87 +46,101 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DatabaseWatcherSharedPrivateLinkResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherSharedPrivateLinkResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DatabaseWatcherSharedPrivateLinkResourceData)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(DatabaseWatcherSharedPrivateLinkResourceData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherSharedPrivateLinkResourceData(document.RootElement, options); } - internal static DatabaseWatcherSharedPrivateLinkResourceData DeserializeDatabaseWatcherSharedPrivateLinkResourceData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DatabaseWatcherSharedPrivateLinkResourceData DeserializeDatabaseWatcherSharedPrivateLinkResourceData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DatabaseWatcherSharedPrivateLinkResourceProperties properties = 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(); + DatabaseWatcherSharedPrivateLinkResourceProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = DatabaseWatcherSharedPrivateLinkResourceProperties.DeserializeDatabaseWatcherSharedPrivateLinkResourceProperties(property.Value, options); + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("name"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("type"u8)) { - name = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("systemData"u8)) { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDatabaseWatcherContext.Default); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("properties"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, AzureResourceManagerDatabaseWatcherContext.Default); + properties = DatabaseWatcherSharedPrivateLinkResourceProperties.DeserializeDatabaseWatcherSharedPrivateLinkResourceProperties(prop.Value, options); 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 DatabaseWatcherSharedPrivateLinkResourceData( id, name, - type, + resourceType, systemData, - properties, - serializedAdditionalRawData); + additionalBinaryDataProperties, + properties); } - 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 +150,20 @@ BinaryData IPersistableModel.Write } } - DatabaseWatcherSharedPrivateLinkResourceData 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. + DatabaseWatcherSharedPrivateLinkResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DatabaseWatcherSharedPrivateLinkResourceData)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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherSharedPrivateLinkResourceData(document.RootElement, options); } default: @@ -151,6 +171,27 @@ DatabaseWatcherSharedPrivateLinkResourceData IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DatabaseWatcherSharedPrivateLinkResourceData databaseWatcherSharedPrivateLinkResourceData) + { + if (databaseWatcherSharedPrivateLinkResourceData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(databaseWatcherSharedPrivateLinkResourceData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static DatabaseWatcherSharedPrivateLinkResourceData FromResponse(Response result) + { + using Response response = result; + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeDatabaseWatcherSharedPrivateLinkResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResourceData.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResourceData.cs index 1d5c00501987..029c4f28ef2b 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResourceData.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherSharedPrivateLinkResourceData.cs @@ -13,43 +13,11 @@ namespace Azure.ResourceManager.DatabaseWatcher { - /// - /// A class representing the DatabaseWatcherSharedPrivateLinkResource data model. - /// Concrete proxy resource types can be created by aliasing this type using a specific property type. - /// + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. public partial class DatabaseWatcherSharedPrivateLinkResourceData : ResourceData { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public DatabaseWatcherSharedPrivateLinkResourceData() @@ -57,16 +25,16 @@ public DatabaseWatcherSharedPrivateLinkResourceData() } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. + /// 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. /// The resource-specific properties for this resource. - /// Keeps track of any properties unknown to the library. - internal DatabaseWatcherSharedPrivateLinkResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, DatabaseWatcherSharedPrivateLinkResourceProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + internal DatabaseWatcherSharedPrivateLinkResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, DatabaseWatcherSharedPrivateLinkResourceProperties properties) : base(id, name, resourceType, systemData) { + _additionalBinaryDataProperties = additionalBinaryDataProperties; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; } /// The resource-specific properties for this resource. diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetCollection.cs index 8f123e9e4ce0..9e56f7680f99 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetCollection.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetCollection.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; namespace Azure.ResourceManager.DatabaseWatcher { @@ -24,51 +25,49 @@ namespace Azure.ResourceManager.DatabaseWatcher /// public partial class DatabaseWatcherTargetCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _databaseWatcherTargetTargetsClientDiagnostics; - private readonly TargetsRestOperations _databaseWatcherTargetTargetsRestClient; + private readonly ClientDiagnostics _targetsClientDiagnostics; + private readonly Targets _targetsRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DatabaseWatcherTargetCollection for mocking. protected DatabaseWatcherTargetCollection() { } - /// 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 DatabaseWatcherTargetCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _databaseWatcherTargetTargetsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", DatabaseWatcherTargetResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(DatabaseWatcherTargetResource.ResourceType, out string databaseWatcherTargetTargetsApiVersion); - _databaseWatcherTargetTargetsRestClient = new TargetsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, databaseWatcherTargetTargetsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(DatabaseWatcherTargetResource.ResourceType, out string databaseWatcherTargetApiVersion); + _targetsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", DatabaseWatcherTargetResource.ResourceType.Namespace, Diagnostics); + _targetsRestClient = new Targets(_targetsClientDiagnostics, Pipeline, Endpoint, databaseWatcherTargetApiVersion ?? "2025-01-02"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != DatabaseWatcherResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, DatabaseWatcherResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, DatabaseWatcherResource.ResourceType), id); + } } /// /// Create a Target /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} - /// - /// - /// Operation Id - /// Target_CreateOrUpdate + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Targets_CreateOrUpdate. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -76,23 +75,31 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// The target resource name. /// Resource create parameters. /// 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 targetName, DatabaseWatcherTargetData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _databaseWatcherTargetTargetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.CreateOrUpdate"); + using DiagnosticScope scope = _targetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _databaseWatcherTargetTargetsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, data, cancellationToken).ConfigureAwait(false); - var uri = _databaseWatcherTargetTargetsRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherTargetResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _targetsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, targetName, DatabaseWatcherTargetData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherTargetData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherTargetResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -106,20 +113,16 @@ public virtual async Task> CreateOrU /// Create a Target /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}. /// /// - /// Operation Id - /// Target_CreateOrUpdate + /// Operation Id. + /// Targets_CreateOrUpdate. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -127,23 +130,31 @@ public virtual async Task> CreateOrU /// The target resource name. /// Resource create parameters. /// 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 targetName, DatabaseWatcherTargetData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _databaseWatcherTargetTargetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.CreateOrUpdate"); + using DiagnosticScope scope = _targetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.CreateOrUpdate"); scope.Start(); try { - var response = _databaseWatcherTargetTargetsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, data, cancellationToken); - var uri = _databaseWatcherTargetTargetsRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherTargetResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _targetsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, targetName, DatabaseWatcherTargetData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherTargetData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherTargetResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -157,38 +168,42 @@ public virtual ArmOperation CreateOrUpdate(WaitUn /// Get a Target /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} - /// - /// - /// Operation Id - /// Target_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Targets_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The target resource name. /// 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 targetName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); - using var scope = _databaseWatcherTargetTargetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.Get"); + using DiagnosticScope scope = _targetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.Get"); scope.Start(); try { - var response = await _databaseWatcherTargetTargetsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _targetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, targetName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherTargetData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherTargetResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -202,38 +217,42 @@ public virtual async Task> GetAsync(stri /// Get a Target /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} - /// - /// - /// Operation Id - /// Target_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Targets_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The target resource name. /// 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 targetName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); - using var scope = _databaseWatcherTargetTargetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.Get"); + using DiagnosticScope scope = _targetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.Get"); scope.Start(); try { - var response = _databaseWatcherTargetTargetsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _targetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, targetName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherTargetData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherTargetResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -247,50 +266,44 @@ public virtual Response Get(string targetName, Ca /// List Target resources by Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets. /// /// - /// Operation Id - /// Target_ListByWatcher + /// Operation Id. + /// Targets_ListByWatcher. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// 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) => _databaseWatcherTargetTargetsRestClient.CreateListByWatcherRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _databaseWatcherTargetTargetsRestClient.CreateListByWatcherNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DatabaseWatcherTargetResource(Client, DatabaseWatcherTargetData.DeserializeDatabaseWatcherTargetData(e)), _databaseWatcherTargetTargetsClientDiagnostics, Pipeline, "DatabaseWatcherTargetCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new TargetsGetByWatcherAsyncCollectionResultOfT(_targetsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new DatabaseWatcherTargetResource(Client, data)); } /// /// List Target resources by Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets - /// - /// - /// Operation Id - /// Target_ListByWatcher + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Targets_ListByWatcher. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -298,45 +311,61 @@ public virtual AsyncPageable GetAllAsync(Cancella /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _databaseWatcherTargetTargetsRestClient.CreateListByWatcherRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _databaseWatcherTargetTargetsRestClient.CreateListByWatcherNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DatabaseWatcherTargetResource(Client, DatabaseWatcherTargetData.DeserializeDatabaseWatcherTargetData(e)), _databaseWatcherTargetTargetsClientDiagnostics, Pipeline, "DatabaseWatcherTargetCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new TargetsGetByWatcherCollectionResultOfT(_targetsRestClient, Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, context), data => new DatabaseWatcherTargetResource(Client, data)); } /// - /// Checks to see if the resource exists in azure. + /// Get a Target /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}. /// /// - /// Operation Id - /// Target_Get + /// Operation Id. + /// Targets_Get. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The target resource name. /// 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 targetName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); - using var scope = _databaseWatcherTargetTargetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.Exists"); + using DiagnosticScope scope = _targetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.Exists"); scope.Start(); try { - var response = await _databaseWatcherTargetTargetsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _targetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, targetName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherTargetData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherTargetData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -347,39 +376,53 @@ public virtual async Task> ExistsAsync(string targetName, Cancell } /// - /// Checks to see if the resource exists in azure. + /// Get a Target /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} - /// - /// - /// Operation Id - /// Target_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Targets_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The target resource name. /// 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 targetName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); - using var scope = _databaseWatcherTargetTargetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.Exists"); + using DiagnosticScope scope = _targetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.Exists"); scope.Start(); try { - var response = _databaseWatcherTargetTargetsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _targetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, targetName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherTargetData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherTargetData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -390,41 +433,57 @@ public virtual Response Exists(string targetName, CancellationToken cancel } /// - /// Tries to get details for this resource from the service. + /// Get a Target /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} - /// - /// - /// Operation Id - /// Target_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Targets_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The target resource name. /// 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 targetName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); - using var scope = _databaseWatcherTargetTargetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.GetIfExists"); + using DiagnosticScope scope = _targetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.GetIfExists"); scope.Start(); try { - var response = await _databaseWatcherTargetTargetsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _targetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, targetName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherTargetData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherTargetData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherTargetResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -435,41 +494,57 @@ public virtual async Task> GetIf } /// - /// Tries to get details for this resource from the service. + /// Get a Target /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}. /// /// - /// Operation Id - /// Target_Get + /// Operation Id. + /// Targets_Get. /// /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// The target resource name. /// 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 targetName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); - using var scope = _databaseWatcherTargetTargetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.GetIfExists"); + using DiagnosticScope scope = _targetsClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.GetIfExists"); scope.Start(); try { - var response = _databaseWatcherTargetTargetsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _targetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Name, targetName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(DatabaseWatcherTargetData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((DatabaseWatcherTargetData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherTargetResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -489,6 +564,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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetData.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetData.Serialization.cs index 049314b74c44..75d1e717fa26 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetData.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetData.Serialization.cs @@ -10,16 +10,18 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.DatabaseWatcher.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DatabaseWatcher { - public partial class DatabaseWatcherTargetData : IUtf8JsonSerializable, IJsonModel + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + public partial class DatabaseWatcherTargetData : ResourceData, 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(); @@ -31,12 +33,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea /// 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(DatabaseWatcherTargetData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Properties)) { @@ -45,87 +46,101 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - DatabaseWatcherTargetData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherTargetData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DatabaseWatcherTargetData)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(DatabaseWatcherTargetData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherTargetData(document.RootElement, options); } - internal static DatabaseWatcherTargetData DeserializeDatabaseWatcherTargetData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DatabaseWatcherTargetData DeserializeDatabaseWatcherTargetData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DatabaseWatcherTargetProperties properties = 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(); + DatabaseWatcherTargetProperties properties = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("id"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = DatabaseWatcherTargetProperties.DeserializeDatabaseWatcherTargetProperties(property.Value, options); + id = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("name"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + name = prop.Value.GetString(); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("type"u8)) { - name = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("systemData"u8)) { - type = new ResourceType(property.Value.GetString()); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDatabaseWatcherContext.Default); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("properties"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, AzureResourceManagerDatabaseWatcherContext.Default); + properties = DatabaseWatcherTargetProperties.DeserializeDatabaseWatcherTargetProperties(prop.Value, options); 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 DatabaseWatcherTargetData( id, name, - type, + resourceType, systemData, - properties, - serializedAdditionalRawData); + additionalBinaryDataProperties, + properties); } - 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 +150,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO } } - DatabaseWatcherTargetData 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. + DatabaseWatcherTargetData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DatabaseWatcherTargetData)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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherTargetData(document.RootElement, options); } default: @@ -151,6 +171,27 @@ DatabaseWatcherTargetData IPersistableModel.Create(Bi } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DatabaseWatcherTargetData databaseWatcherTargetData) + { + if (databaseWatcherTargetData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(databaseWatcherTargetData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static DatabaseWatcherTargetData FromResponse(Response result) + { + using Response response = result; + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeDatabaseWatcherTargetData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetData.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetData.cs index 6dd1c1056cc7..953348d1560b 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetData.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetData.cs @@ -13,43 +13,11 @@ namespace Azure.ResourceManager.DatabaseWatcher { - /// - /// A class representing the DatabaseWatcherTarget data model. - /// Concrete proxy resource types can be created by aliasing this type using a specific property type. - /// + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. public partial class DatabaseWatcherTargetData : ResourceData { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public DatabaseWatcherTargetData() @@ -57,27 +25,19 @@ public DatabaseWatcherTargetData() } /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// - /// The resource-specific properties for this resource. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . - /// - /// Keeps track of any properties unknown to the library. - internal DatabaseWatcherTargetData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, DatabaseWatcherTargetProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + /// 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. + /// The resource-specific properties for this resource. + internal DatabaseWatcherTargetData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, DatabaseWatcherTargetProperties properties) : base(id, name, resourceType, systemData) { + _additionalBinaryDataProperties = additionalBinaryDataProperties; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; } - /// - /// The resource-specific properties for this resource. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . - /// + /// The resource-specific properties for this resource. public DatabaseWatcherTargetProperties Properties { get; set; } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetResource.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetResource.Serialization.cs index 2d44a5f92710..6761879af919 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetResource.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetResource.Serialization.cs @@ -11,19 +11,29 @@ namespace Azure.ResourceManager.DatabaseWatcher { + /// public partial class DatabaseWatcherTargetResource : IJsonModel { - private static DatabaseWatcherTargetData s_dataDeserializationInstance; - private static DatabaseWatcherTargetData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new DatabaseWatcherTargetData(); + + /// 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); - DatabaseWatcherTargetData 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. + DatabaseWatcherTargetData 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, AzureResourceManagerDatabaseWatcherContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. DatabaseWatcherTargetData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerDatabaseWatcherContext.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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetResource.cs index 12e73b59504f..e46a9949f579 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetResource.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/DatabaseWatcherTargetResource.cs @@ -6,46 +6,35 @@ #nullable disable using System; -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; namespace Azure.ResourceManager.DatabaseWatcher { /// - /// A Class representing a DatabaseWatcherTarget 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 GetDatabaseWatcherTargetResource method. - /// Otherwise you can get one from its parent resource using the GetDatabaseWatcherTarget method. + /// A class representing a DatabaseWatcherTarget 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 GetDatabaseWatcherTargets method. /// public partial class DatabaseWatcherTargetResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The watcherName. - /// The targetName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string targetName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _databaseWatcherTargetTargetsClientDiagnostics; - private readonly TargetsRestOperations _databaseWatcherTargetTargetsRestClient; + private readonly ClientDiagnostics _targetsClientDiagnostics; + private readonly Targets _targetsRestClient; private readonly DatabaseWatcherTargetData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.DatabaseWatcher/watchers/targets"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of DatabaseWatcherTargetResource for mocking. protected DatabaseWatcherTargetResource() { } - /// 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 DatabaseWatcherTargetResource(ArmClient client, DatabaseWatcherTargetData data) : this(client, data.Id) @@ -54,71 +43,93 @@ internal DatabaseWatcherTargetResource(ArmClient client, DatabaseWatcherTargetDa _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 DatabaseWatcherTargetResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _databaseWatcherTargetTargetsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string databaseWatcherTargetTargetsApiVersion); - _databaseWatcherTargetTargetsRestClient = new TargetsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, databaseWatcherTargetTargetsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string databaseWatcherTargetApiVersion); + _targetsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); + _targetsRestClient = new Targets(_targetsClientDiagnostics, Pipeline, Endpoint, databaseWatcherTargetApiVersion ?? "2025-01-02"); + 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 DatabaseWatcherTargetData 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 watcherName. + /// The targetName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string targetName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}"; + 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 Target /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}. /// /// - /// Operation Id - /// Target_Get + /// Operation Id. + /// Targets_Get. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherTargetTargetsClientDiagnostics.CreateScope("DatabaseWatcherTargetResource.Get"); + using DiagnosticScope scope = _targetsClientDiagnostics.CreateScope("DatabaseWatcherTargetResource.Get"); scope.Start(); try { - var response = await _databaseWatcherTargetTargetsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _targetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherTargetData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherTargetResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -132,33 +143,41 @@ public virtual async Task> GetAsync(Canc /// Get a Target /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}. /// /// - /// Operation Id - /// Target_Get + /// Operation Id. + /// Targets_Get. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherTargetTargetsClientDiagnostics.CreateScope("DatabaseWatcherTargetResource.Get"); + using DiagnosticScope scope = _targetsClientDiagnostics.CreateScope("DatabaseWatcherTargetResource.Get"); scope.Start(); try { - var response = _databaseWatcherTargetTargetsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _targetsRestClient.CreateGetRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherTargetData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new DatabaseWatcherTargetResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -172,20 +191,20 @@ public virtual Response Get(CancellationToken can /// Delete a Target /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}. /// /// - /// Operation Id - /// Target_Delete + /// Operation Id. + /// Targets_Delete. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -193,16 +212,23 @@ public virtual Response Get(CancellationToken can /// The cancellation token to use. public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherTargetTargetsClientDiagnostics.CreateScope("DatabaseWatcherTargetResource.Delete"); + using DiagnosticScope scope = _targetsClientDiagnostics.CreateScope("DatabaseWatcherTargetResource.Delete"); scope.Start(); try { - var response = await _databaseWatcherTargetTargetsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); - var uri = _databaseWatcherTargetTargetsRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DatabaseWatcherArmOperation(response, rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _targetsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(response, rehydrationToken); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -216,20 +242,20 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// Delete a Target /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}. /// /// - /// Operation Id - /// Target_Delete + /// Operation Id. + /// Targets_Delete. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -237,16 +263,23 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell /// The cancellation token to use. public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - using var scope = _databaseWatcherTargetTargetsClientDiagnostics.CreateScope("DatabaseWatcherTargetResource.Delete"); + using DiagnosticScope scope = _targetsClientDiagnostics.CreateScope("DatabaseWatcherTargetResource.Delete"); scope.Start(); try { - var response = _databaseWatcherTargetTargetsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); - var uri = _databaseWatcherTargetTargetsRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DatabaseWatcherArmOperation(response, rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _targetsRestClient.CreateDeleteRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(response, rehydrationToken); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletionResponse(cancellationToken); + } return operation; } catch (Exception e) @@ -260,20 +293,20 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel /// Create a Target /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}. /// /// - /// Operation Id - /// Target_CreateOrUpdate + /// Operation Id. + /// Targets_CreateOrUpdate. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -285,16 +318,24 @@ public virtual async Task> UpdateAsy { Argument.AssertNotNull(data, nameof(data)); - using var scope = _databaseWatcherTargetTargetsClientDiagnostics.CreateScope("DatabaseWatcherTargetResource.Update"); + using DiagnosticScope scope = _targetsClientDiagnostics.CreateScope("DatabaseWatcherTargetResource.Update"); scope.Start(); try { - var response = await _databaseWatcherTargetTargetsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); - var uri = _databaseWatcherTargetTargetsRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherTargetResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _targetsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, DatabaseWatcherTargetData.ToRequestContent(data), context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(DatabaseWatcherTargetData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherTargetResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -308,20 +349,20 @@ public virtual async Task> UpdateAsy /// Create a Target /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName}. /// /// - /// Operation Id - /// Target_CreateOrUpdate + /// Operation Id. + /// Targets_CreateOrUpdate. /// /// - /// Default Api Version - /// 2025-01-02 + /// Default Api Version. + /// 2025-01-02. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// @@ -333,16 +374,24 @@ public virtual ArmOperation Update(WaitUntil wait { Argument.AssertNotNull(data, nameof(data)); - using var scope = _databaseWatcherTargetTargetsClientDiagnostics.CreateScope("DatabaseWatcherTargetResource.Update"); + using DiagnosticScope scope = _targetsClientDiagnostics.CreateScope("DatabaseWatcherTargetResource.Update"); scope.Start(); try { - var response = _databaseWatcherTargetTargetsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); - var uri = _databaseWatcherTargetTargetsRestClient.CreateCreateOrUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data); - var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); - var operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherTargetResource(Client, response), response.GetRawResponse()), rehydrationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _targetsRestClient.CreateCreateOrUpdateRequest(Guid.Parse(Id.SubscriptionId), Id.ResourceGroupName, Id.Parent.Name, Id.Name, DatabaseWatcherTargetData.ToRequestContent(data), context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(DatabaseWatcherTargetData.FromResponse(result), result); + RequestUriBuilder uri = message.Request.Uri; + RehydrationToken rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Put, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + DatabaseWatcherArmOperation operation = new DatabaseWatcherArmOperation(Response.FromValue(new DatabaseWatcherTargetResource(Client, response.Value), response.GetRawResponse()), rehydrationToken); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/DatabaseWatcherExtensions.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/DatabaseWatcherExtensions.cs index 6afb25cd9e8f..e94321a284d0 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/DatabaseWatcherExtensions.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/DatabaseWatcherExtensions.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.DatabaseWatcher.Mocking; using Azure.ResourceManager.Resources; @@ -17,30 +19,26 @@ namespace Azure.ResourceManager.DatabaseWatcher /// A class to add extension methods to Azure.ResourceManager.DatabaseWatcher. public static partial class DatabaseWatcherExtensions { + /// private static MockableDatabaseWatcherArmClient GetMockableDatabaseWatcherArmClient(ArmClient client) { - return client.GetCachedClient(client0 => new MockableDatabaseWatcherArmClient(client0)); + return client.GetCachedClient(client0 => new MockableDatabaseWatcherArmClient(client0, ResourceIdentifier.Root)); } - private static MockableDatabaseWatcherResourceGroupResource GetMockableDatabaseWatcherResourceGroupResource(ArmResource resource) + /// + private static MockableDatabaseWatcherResourceGroupResource GetMockableDatabaseWatcherResourceGroupResource(ResourceGroupResource resourceGroupResource) { - return resource.GetCachedClient(client => new MockableDatabaseWatcherResourceGroupResource(client, resource.Id)); + return resourceGroupResource.GetCachedClient(client => new MockableDatabaseWatcherResourceGroupResource(client, resourceGroupResource.Id)); } - private static MockableDatabaseWatcherSubscriptionResource GetMockableDatabaseWatcherSubscriptionResource(ArmResource resource) + /// + private static MockableDatabaseWatcherSubscriptionResource GetMockableDatabaseWatcherSubscriptionResource(SubscriptionResource subscriptionResource) { - return resource.GetCachedClient(client => new MockableDatabaseWatcherSubscriptionResource(client, resource.Id)); + return subscriptionResource.GetCachedClient(client => new MockableDatabaseWatcherSubscriptionResource(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. - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. /// Returns a object. @@ -51,15 +49,8 @@ public static DatabaseWatcherResource GetDatabaseWatcherResource(this ArmClient return GetMockableDatabaseWatcherArmClient(client).GetDatabaseWatcherResource(id); } - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. /// Returns a object. @@ -70,15 +61,8 @@ public static DatabaseWatcherAlertRuleResource GetDatabaseWatcherAlertRuleResour return GetMockableDatabaseWatcherArmClient(client).GetDatabaseWatcherAlertRuleResource(id); } - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. /// Returns a object. @@ -89,15 +73,8 @@ public static DatabaseWatcherHealthValidationResource GetDatabaseWatcherHealthVa return GetMockableDatabaseWatcherArmClient(client).GetDatabaseWatcherHealthValidationResource(id); } - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. /// Returns a object. @@ -108,15 +85,8 @@ public static DatabaseWatcherTargetResource GetDatabaseWatcherTargetResource(thi return GetMockableDatabaseWatcherArmClient(client).GetDatabaseWatcherTargetResource(id); } - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. /// Returns a object. @@ -127,16 +97,10 @@ public static DatabaseWatcherSharedPrivateLinkResource GetDatabaseWatcherSharedP return GetMockableDatabaseWatcherArmClient(client).GetDatabaseWatcherSharedPrivateLinkResource(id); } - /// - /// Gets a collection of DatabaseWatcherResources in the ResourceGroupResource. - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. + /// Gets a collection of DatabaseWatchers in the . + /// The the method will execute against. /// is null. - /// An object representing collection of DatabaseWatcherResources and their operations over a DatabaseWatcherResource. + /// An object representing collection of DatabaseWatchers and their operations over a DatabaseWatcherResource. public static DatabaseWatcherCollection GetDatabaseWatchers(this ResourceGroupResource resourceGroupResource) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -144,36 +108,11 @@ public static DatabaseWatcherCollection GetDatabaseWatchers(this ResourceGroupRe return GetMockableDatabaseWatcherResourceGroupResource(resourceGroupResource).GetDatabaseWatchers(); } - /// - /// Get a Watcher - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. + /// Get a Watcher. + /// The the method will execute against. /// The database watcher name. /// 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> GetDatabaseWatcherAsync(this ResourceGroupResource resourceGroupResource, string watcherName, CancellationToken cancellationToken = default) { @@ -182,36 +121,11 @@ public static async Task> GetDatabaseWatcherAs return await GetMockableDatabaseWatcherResourceGroupResource(resourceGroupResource).GetDatabaseWatcherAsync(watcherName, cancellationToken).ConfigureAwait(false); } - /// - /// Get a Watcher - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_Get - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. + /// Get a Watcher. + /// The the method will execute against. /// The database watcher name. /// 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 GetDatabaseWatcher(this ResourceGroupResource resourceGroupResource, string watcherName, CancellationToken cancellationToken = default) { @@ -220,35 +134,11 @@ public static Response GetDatabaseWatcher(this Resource return GetMockableDatabaseWatcherResourceGroupResource(resourceGroupResource).GetDatabaseWatcher(watcherName, cancellationToken); } - /// - /// List Watcher resources by subscription ID - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DatabaseWatcher/watchers - /// - /// - /// Operation Id - /// Watcher_ListBySubscription - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. + /// List Watcher resources by subscription ID. + /// 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 GetDatabaseWatchersAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); @@ -256,32 +146,8 @@ public static AsyncPageable GetDatabaseWatchersAsync(th return GetMockableDatabaseWatcherSubscriptionResource(subscriptionResource).GetDatabaseWatchersAsync(cancellationToken); } - /// - /// List Watcher resources by subscription ID - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DatabaseWatcher/watchers - /// - /// - /// Operation Id - /// Watcher_ListBySubscription - /// - /// - /// Default Api Version - /// 2025-01-02 - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. - /// - /// - /// The instance the method will execute against. + /// List Watcher resources by subscription ID. + /// 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherArmClient.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherArmClient.cs index 19aa6740f0fb..e8d754e703bf 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherArmClient.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherArmClient.cs @@ -6,38 +6,27 @@ #nullable disable using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Mocking { - /// A class to add extension methods to ArmClient. + /// A class to add extension methods to . public partial class MockableDatabaseWatcherArmClient : ArmResource { - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableDatabaseWatcherArmClient for mocking. protected MockableDatabaseWatcherArmClient() { } - /// 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 MockableDatabaseWatcherArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) { } - internal MockableDatabaseWatcherArmClient(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 DatabaseWatcherResource GetDatabaseWatcherResource(ResourceIdentifier id) @@ -46,10 +35,7 @@ public virtual DatabaseWatcherResource GetDatabaseWatcherResource(ResourceIdenti return new DatabaseWatcherResource(Client, 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. /// The resource ID of the resource to get. /// Returns a object. public virtual DatabaseWatcherAlertRuleResource GetDatabaseWatcherAlertRuleResource(ResourceIdentifier id) @@ -58,10 +44,7 @@ public virtual DatabaseWatcherAlertRuleResource GetDatabaseWatcherAlertRuleResou return new DatabaseWatcherAlertRuleResource(Client, 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. /// The resource ID of the resource to get. /// Returns a object. public virtual DatabaseWatcherHealthValidationResource GetDatabaseWatcherHealthValidationResource(ResourceIdentifier id) @@ -70,10 +53,7 @@ public virtual DatabaseWatcherHealthValidationResource GetDatabaseWatcherHealthV return new DatabaseWatcherHealthValidationResource(Client, 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. /// The resource ID of the resource to get. /// Returns a object. public virtual DatabaseWatcherTargetResource GetDatabaseWatcherTargetResource(ResourceIdentifier id) @@ -82,10 +62,7 @@ public virtual DatabaseWatcherTargetResource GetDatabaseWatcherTargetResource(Re return new DatabaseWatcherTargetResource(Client, 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. /// The resource ID of the resource to get. /// Returns a object. public virtual DatabaseWatcherSharedPrivateLinkResource GetDatabaseWatcherSharedPrivateLinkResource(ResourceIdentifier id) diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherResourceGroupResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherResourceGroupResource.cs index b0cfc6f02f62..7c7ff6a38c3a 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherResourceGroupResource.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherResourceGroupResource.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.DatabaseWatcher; +using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.DatabaseWatcher.Mocking { - /// A class to add extension methods to ResourceGroupResource. + /// A class to add extension methods to . public partial class MockableDatabaseWatcherResourceGroupResource : ArmResource { - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableDatabaseWatcherResourceGroupResource for mocking. protected MockableDatabaseWatcherResourceGroupResource() { } - /// 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 MockableDatabaseWatcherResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of DatabaseWatcherResources in the ResourceGroupResource. - /// An object representing collection of DatabaseWatcherResources and their operations over a DatabaseWatcherResource. + /// Gets a collection of DatabaseWatchers in the . + /// An object representing collection of DatabaseWatchers and their operations over a DatabaseWatcherResource. public virtual DatabaseWatcherCollection GetDatabaseWatchers() { return GetCachedClient(client => new DatabaseWatcherCollection(client, Id)); @@ -44,20 +42,16 @@ public virtual DatabaseWatcherCollection GetDatabaseWatchers() /// Get a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Watchers_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -68,6 +62,8 @@ public virtual DatabaseWatcherCollection GetDatabaseWatchers() [ForwardsClientCalls] public virtual async Task> GetDatabaseWatcherAsync(string watcherName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + return await GetDatabaseWatchers().GetAsync(watcherName, cancellationToken).ConfigureAwait(false); } @@ -75,20 +71,16 @@ public virtual async Task> GetDatabaseWatcherA /// Get a Watcher /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} - /// - /// - /// Operation Id - /// Watcher_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Watchers_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -99,6 +91,8 @@ public virtual async Task> GetDatabaseWatcherA [ForwardsClientCalls] public virtual Response GetDatabaseWatcher(string watcherName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + return GetDatabaseWatchers().Get(watcherName, cancellationToken); } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherSubscriptionResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherSubscriptionResource.cs index 9b8b00ee8cc4..368b7ca825d4 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherSubscriptionResource.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherSubscriptionResource.cs @@ -5,88 +5,81 @@ #nullable disable +using System; using System.Threading; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.DatabaseWatcher; +using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.DatabaseWatcher.Mocking { - /// A class to add extension methods to SubscriptionResource. + /// A class to add extension methods to . public partial class MockableDatabaseWatcherSubscriptionResource : ArmResource { - private ClientDiagnostics _databaseWatcherWatchersClientDiagnostics; - private WatchersRestOperations _databaseWatcherWatchersRestClient; + private ClientDiagnostics _watchersClientDiagnostics; + private Watchers _watchersRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableDatabaseWatcherSubscriptionResource for mocking. protected MockableDatabaseWatcherSubscriptionResource() { } - /// 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 MockableDatabaseWatcherSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private ClientDiagnostics DatabaseWatcherWatchersClientDiagnostics => _databaseWatcherWatchersClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", DatabaseWatcherResource.ResourceType.Namespace, Diagnostics); - private WatchersRestOperations DatabaseWatcherWatchersRestClient => _databaseWatcherWatchersRestClient ??= new WatchersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(DatabaseWatcherResource.ResourceType)); + private ClientDiagnostics WatchersClientDiagnostics => _watchersClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } + private Watchers WatchersRestClient => _watchersRestClient ??= new Watchers(WatchersClientDiagnostics, Pipeline, Endpoint, "2025-01-02"); /// /// List Watcher resources by subscription ID /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DatabaseWatcher/watchers - /// - /// - /// Operation Id - /// Watcher_ListBySubscription + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.DatabaseWatcher/watchers. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Watchers_ListBySubscription. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// /// 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 GetDatabaseWatchersAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => DatabaseWatcherWatchersRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DatabaseWatcherWatchersRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new DatabaseWatcherResource(Client, DatabaseWatcherData.DeserializeDatabaseWatcherData(e)), DatabaseWatcherWatchersClientDiagnostics, Pipeline, "MockableDatabaseWatcherSubscriptionResource.GetDatabaseWatchers", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new WatchersGetBySubscriptionAsyncCollectionResultOfT(WatchersRestClient, Guid.Parse(Id.SubscriptionId), context), data => new DatabaseWatcherResource(Client, data)); } /// /// List Watcher resources by subscription ID /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.DatabaseWatcher/watchers - /// - /// - /// Operation Id - /// Watcher_ListBySubscription + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.DatabaseWatcher/watchers. /// /// - /// Default Api Version - /// 2025-01-02 + /// Operation Id. + /// Watchers_ListBySubscription. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-01-02. /// /// /// @@ -94,9 +87,11 @@ public virtual AsyncPageable GetDatabaseWatchersAsync(C /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetDatabaseWatchers(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => DatabaseWatcherWatchersRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => DatabaseWatcherWatchersRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new DatabaseWatcherResource(Client, DatabaseWatcherData.DeserializeDatabaseWatcherData(e)), DatabaseWatcherWatchersClientDiagnostics, Pipeline, "MockableDatabaseWatcherSubscriptionResource.GetDatabaseWatchers", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new WatchersGetBySubscriptionCollectionResultOfT(WatchersRestClient, Guid.Parse(Id.SubscriptionId), context), data => new DatabaseWatcherResource(Client, data)); } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationsGetByParentAsyncCollectionResultOfT.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationsGetByParentAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..c28b87b0ef20 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationsGetByParentAsyncCollectionResultOfT.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class HealthValidationsGetByParentAsyncCollectionResultOfT : AsyncPageable + { + private readonly HealthValidations _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _watcherName; + private readonly RequestContext _context; + + /// Initializes a new instance of HealthValidationsGetByParentAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The HealthValidations 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 database watcher name. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public HealthValidationsGetByParentAsyncCollectionResultOfT(HealthValidations client, Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _watcherName = watcherName; + _context = context; + } + + /// Gets the pages of HealthValidationsGetByParentAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of HealthValidationsGetByParentAsyncCollectionResultOfT 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; + } + HealthValidationListResult result = HealthValidationListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)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.CreateNextGetByParentRequest(nextLink, _subscriptionId, _resourceGroupName, _watcherName, _context) : _client.CreateGetByParentRequest(_subscriptionId, _resourceGroupName, _watcherName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationsGetByParentCollectionResultOfT.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationsGetByParentCollectionResultOfT.cs new file mode 100644 index 000000000000..19b00576557a --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationsGetByParentCollectionResultOfT.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class HealthValidationsGetByParentCollectionResultOfT : Pageable + { + private readonly HealthValidations _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _watcherName; + private readonly RequestContext _context; + + /// Initializes a new instance of HealthValidationsGetByParentCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The HealthValidations 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 database watcher name. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public HealthValidationsGetByParentCollectionResultOfT(HealthValidations client, Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _watcherName = watcherName; + _context = context; + } + + /// Gets the pages of HealthValidationsGetByParentCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of HealthValidationsGetByParentCollectionResultOfT 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; + } + HealthValidationListResult result = HealthValidationListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)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.CreateNextGetByParentRequest(nextLink, _subscriptionId, _resourceGroupName, _watcherName, _context) : _client.CreateGetByParentRequest(_subscriptionId, _resourceGroupName, _watcherName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DatabaseWatcherHealthValidationCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Argument.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Argument.cs index 32f9b26aaec4..a7f14adb2a64 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Argument.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Argument.cs @@ -11,8 +11,10 @@ namespace Azure.ResourceManager.DatabaseWatcher { - 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..9c2d90740ad0 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/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.DatabaseWatcher +{ + 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ChangeTrackingDictionary.cs index 6afbde7e464c..08866c4ff956 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ChangeTrackingDictionary.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -11,7 +11,8 @@ namespace Azure.ResourceManager.DatabaseWatcher { - 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ChangeTrackingList.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ChangeTrackingList.cs index 7d07be2128e8..13cccd21be36 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ChangeTrackingList.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ChangeTrackingList.cs @@ -12,7 +12,7 @@ namespace Azure.ResourceManager.DatabaseWatcher { - 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..ff2119b2282c --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/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.DatabaseWatcher +{ + 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..dc39110e0e40 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/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 Azure.ResourceManager.DatabaseWatcher +{ + [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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..11342aa6bce2 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/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 Azure.ResourceManager.DatabaseWatcher +{ + [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 propertySerializationName) + { + PropertyName = propertyName; + PropertySerializationName = propertySerializationName; + } + + /// 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 PropertySerializationName { 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..b7fb8f1b5f52 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/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 Azure.ResourceManager.DatabaseWatcher +{ + [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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..16c4779913be --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/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 Azure.ResourceManager.DatabaseWatcher +{ + [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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ErrorResult.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..9545be0708b7 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/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.DatabaseWatcher +{ + 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ModelSerializationExtensions.cs index 8b44195a3b9d..878eda79fbe5 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ModelSerializationExtensions.cs @@ -11,18 +11,16 @@ using System.Diagnostics; using System.Globalization; using System.Text.Json; -using System.Xml; -using Azure.Core; namespace Azure.ResourceManager.DatabaseWatcher { - 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 +46,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 +91,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 +105,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 +179,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; @@ -259,151 +254,5 @@ 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 - { - private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; - public const string DefaultNumberFormat = "G"; - - public static string ToString(bool value) => value ? "true" : "false"; - - public static string ToString(DateTime value, string format) => value.Kind switch - { - DateTimeKind.Utc => ToString((DateTimeOffset)value, format), - _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") - }; - - public static string ToString(DateTimeOffset value, string format) => format switch - { - "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), - "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), - "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), - "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), - "R" => value.ToString("r", CultureInfo.InvariantCulture), - _ => value.ToString(format, CultureInfo.InvariantCulture) - }; - - public static string ToString(TimeSpan value, string format) => format switch - { - "P" => XmlConvert.ToString(value), - _ => value.ToString(format, CultureInfo.InvariantCulture) - }; - - public static string ToString(byte[] value, string format) => format switch - { - "U" => ToBase64UrlString(value), - "D" => Convert.ToBase64String(value), - _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) - }; - - public static string ToBase64UrlString(byte[] value) - { - int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; - int size = checked(numWholeOrPartialInputBlocks * 4); - char[] output = new char[size]; - - int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); - - int i = 0; - for (; i < numBase64Chars; i++) - { - char ch = output[i]; - if (ch == '+') - { - output[i] = '-'; - } - else - { - if (ch == '/') - { - output[i] = '_'; - } - else - { - if (ch == '=') - { - break; - } - } - } - } - - return new string(output, 0, i); - } - - public static byte[] FromBase64UrlString(string value) - { - int paddingCharsToAdd = (value.Length % 4) switch - { - 0 => 0, - 2 => 2, - 3 => 1, - _ => throw new InvalidOperationException("Malformed input") - }; - char[] output = new char[(value.Length + paddingCharsToAdd)]; - int i = 0; - for (; i < value.Length; i++) - { - char ch = value[i]; - if (ch == '-') - { - output[i] = '+'; - } - else - { - if (ch == '_') - { - output[i] = '/'; - } - else - { - output[i] = ch; - } - } - } - - for (; i < output.Length; i++) - { - output[i] = '='; - } - - return Convert.FromBase64CharArray(output, 0, output.Length); - } - - public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch - { - "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), - _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) - }; - - public static TimeSpan ParseTimeSpan(string value, string format) => format switch - { - "P" => XmlConvert.ToTimeSpan(value), - _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) - }; - - public static string ConvertToString(object value, string format = null) => value switch - { - null => "null", - string s => s, - bool b => ToString(b), - int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), - byte[] b0 when format != null => ToString(b0, format), - IEnumerable s0 => string.Join(",", s0), - DateTimeOffset dateTime when format != null => ToString(dateTime, format), - TimeSpan timeSpan when format != null => ToString(timeSpan, format), - TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), - Guid guid => guid.ToString(), - BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), - _ => value.ToString() - }; - } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Optional.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Optional.cs index 78fe76f53503..ff470ae2b385 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Optional.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Optional.cs @@ -10,7 +10,7 @@ namespace Azure.ResourceManager.DatabaseWatcher { - 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/PageableWrapper.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..5c8f225f3289 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/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.DatabaseWatcher +{ + 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..99a569bf78b9 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/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.DatabaseWatcher +{ + 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/RequestContextExtensions.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..15d0a326b1ff --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/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.DatabaseWatcher +{ + 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/SerializationFormat.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..90f765d88237 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/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.DatabaseWatcher +{ + 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/TypeFormatters.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..d3d56d0dd0ce --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/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.DatabaseWatcher +{ + 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Utf8JsonRequestContent.cs index e46e08cbf3ee..533d56a01e96 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Utf8JsonRequestContent.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -13,7 +13,7 @@ namespace Azure.ResourceManager.DatabaseWatcher { - 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherArmOperation.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherArmOperation.cs index 0a5d8f346289..edac1da760c0 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherArmOperation.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherArmOperation.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.DatabaseWatcher { -#pragma warning disable SA1649 // File name should match first type name - internal class DatabaseWatcherArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class DatabaseWatcherArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected DatabaseWatcherArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal DatabaseWatcherArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response); @@ -36,12 +37,20 @@ internal DatabaseWatcherArmOperation(Response response, RehydrationToken? rehydr _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 DatabaseWatcherArmOperation(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 DatabaseWatcherArmOperation(ClientDiagnostics clientDiagnostics, HttpPi _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "DatabaseWatcherArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + nextLinkOperation, + clientDiagnostics, + response, + "DatabaseWatcherArmOperation", + 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, AzureResourceManagerDatabaseWatcherContext.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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherArmOperationOfT.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherArmOperationOfT.cs index 20506ab0c17e..25704ab26fb2 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherArmOperationOfT.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherArmOperationOfT.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.DatabaseWatcher { -#pragma warning disable SA1649 // File name should match first type name - internal class DatabaseWatcherArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class DatabaseWatcherArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected DatabaseWatcherArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal DatabaseWatcherArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); @@ -36,12 +37,21 @@ internal DatabaseWatcherArmOperation(Response response, RehydrationToken? reh _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 DatabaseWatcherArmOperation(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 DatabaseWatcherArmOperation(IOperationSource source, ClientDiagnosti _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(NextLinkOperationImplementation.Create(source, nextLinkOperation), clientDiagnostics, response, "DatabaseWatcherArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "DatabaseWatcherArmOperation", + null, + new SequentialDelayStrategy()); } - private string GetOperationId(RehydrationToken? rehydrationToken) - { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerDatabaseWatcherContext.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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherHealthValidationOperationSource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherHealthValidationOperationSource.cs index 21ece446179c..2240871a17dc 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherHealthValidationOperationSource.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherHealthValidationOperationSource.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.DatabaseWatcher { - internal class DatabaseWatcherHealthValidationOperationSource : IOperationSource + /// + internal partial class DatabaseWatcherHealthValidationOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal DatabaseWatcherHealthValidationOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// DatabaseWatcherHealthValidationResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerDatabaseWatcherContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + DatabaseWatcherHealthValidationData data = DatabaseWatcherHealthValidationData.DeserializeDatabaseWatcherHealthValidationData(document.RootElement, ModelSerializationExtensions.WireOptions); return new DatabaseWatcherHealthValidationResource(_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, AzureResourceManagerDatabaseWatcherContext.Default); - return await Task.FromResult(new DatabaseWatcherHealthValidationResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + DatabaseWatcherHealthValidationData data = DatabaseWatcherHealthValidationData.DeserializeDatabaseWatcherHealthValidationData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new DatabaseWatcherHealthValidationResource(_client, data); } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherOperationSource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherOperationSource.cs index 8b7e1c262f09..4a7ce2fb1b01 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherOperationSource.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherOperationSource.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.DatabaseWatcher { - internal class DatabaseWatcherOperationSource : IOperationSource + /// + internal partial class DatabaseWatcherOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal DatabaseWatcherOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// DatabaseWatcherResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerDatabaseWatcherContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + DatabaseWatcherData data = DatabaseWatcherData.DeserializeDatabaseWatcherData(document.RootElement, ModelSerializationExtensions.WireOptions); return new DatabaseWatcherResource(_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, AzureResourceManagerDatabaseWatcherContext.Default); - return await Task.FromResult(new DatabaseWatcherResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + DatabaseWatcherData data = DatabaseWatcherData.DeserializeDatabaseWatcherData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new DatabaseWatcherResource(_client, data); } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherSharedPrivateLinkResourceOperationSource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherSharedPrivateLinkResourceOperationSource.cs index f4aaa45c66ae..760088cdd654 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherSharedPrivateLinkResourceOperationSource.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherSharedPrivateLinkResourceOperationSource.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.DatabaseWatcher { - internal class DatabaseWatcherSharedPrivateLinkResourceOperationSource : IOperationSource + /// + internal partial class DatabaseWatcherSharedPrivateLinkResourceOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal DatabaseWatcherSharedPrivateLinkResourceOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// DatabaseWatcherSharedPrivateLinkResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerDatabaseWatcherContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + DatabaseWatcherSharedPrivateLinkResourceData data = DatabaseWatcherSharedPrivateLinkResourceData.DeserializeDatabaseWatcherSharedPrivateLinkResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); return new DatabaseWatcherSharedPrivateLinkResource(_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, AzureResourceManagerDatabaseWatcherContext.Default); - return await Task.FromResult(new DatabaseWatcherSharedPrivateLinkResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + DatabaseWatcherSharedPrivateLinkResourceData data = DatabaseWatcherSharedPrivateLinkResourceData.DeserializeDatabaseWatcherSharedPrivateLinkResourceData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new DatabaseWatcherSharedPrivateLinkResource(_client, data); } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleCreationProperty.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleCreationProperty.cs index 182479a7ce69..a0cab5031d2d 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleCreationProperty.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleCreationProperty.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { @@ -14,38 +15,57 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models public readonly partial struct AlertRuleCreationProperty : IEquatable { private readonly string _value; + /// The alert rule was created with an action group. + private const string CreatedWithActionGroupValue = "CreatedWithActionGroup"; + /// The alert rule was created with no properties. + private const string NoneValue = "None"; /// Initializes a new instance of . + /// The value. /// is null. public AlertRuleCreationProperty(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string CreatedWithActionGroupValue = "CreatedWithActionGroup"; - private const string NoneValue = "None"; + _value = value; + } /// The alert rule was created with an action group. public static AlertRuleCreationProperty CreatedWithActionGroup { get; } = new AlertRuleCreationProperty(CreatedWithActionGroupValue); + /// The alert rule was created with no properties. public static AlertRuleCreationProperty None { get; } = new AlertRuleCreationProperty(NoneValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(AlertRuleCreationProperty left, AlertRuleCreationProperty right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(AlertRuleCreationProperty left, AlertRuleCreationProperty right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator AlertRuleCreationProperty(string value) => new AlertRuleCreationProperty(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator AlertRuleCreationProperty?(string value) => value == null ? null : new AlertRuleCreationProperty(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is AlertRuleCreationProperty other && Equals(other); - /// + + /// public bool Equals(AlertRuleCreationProperty other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceListResult.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceListResult.Serialization.cs index 2a25da0afb60..d7680e535ed9 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceListResult.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceListResult.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - internal partial class AlertRuleResourceListResult : IUtf8JsonSerializable, IJsonModel + /// The response of a AlertRuleResource list operation. + internal partial class AlertRuleResourceListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal AlertRuleResourceListResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,15 +35,14 @@ 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(AlertRuleResourceListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (DatabaseWatcherAlertRuleData item in Value) { writer.WriteObjectValue(item, options); } @@ -46,15 +52,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink.AbsoluteUri); } - 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); } @@ -63,64 +69,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AlertRuleResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + AlertRuleResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AlertRuleResourceListResult 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(AlertRuleResourceListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeAlertRuleResourceListResult(document.RootElement, options); } - internal static AlertRuleResourceListResult DeserializeAlertRuleResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AlertRuleResourceListResult DeserializeAlertRuleResourceListResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; Uri nextLink = 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("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DatabaseWatcherAlertRuleData.DeserializeDatabaseWatcherAlertRuleData(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nextLink = new Uri(property.Value.GetString()); + nextLink = 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 AlertRuleResourceListResult(value, nextLink, serializedAdditionalRawData); + return new AlertRuleResourceListResult(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": @@ -130,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrite } } - AlertRuleResourceListResult 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. + AlertRuleResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AlertRuleResourceListResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeAlertRuleResourceListResult(document.RootElement, options); } default: @@ -146,6 +163,15 @@ AlertRuleResourceListResult IPersistableModel.Creat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static AlertRuleResourceListResult FromResponse(Response result) + { + using Response response = result; + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeAlertRuleResourceListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceListResult.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceListResult.cs index 758e9310b3d4..1749ec5e2a26 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceListResult.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceListResult.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { /// The response of a AlertRuleResource list operation. internal partial class AlertRuleResourceListResult { - /// - /// 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 AlertRuleResource items on this page. - /// is null. internal AlertRuleResourceListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The AlertRuleResource items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal AlertRuleResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal AlertRuleResourceListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal AlertRuleResourceListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The AlertRuleResource items on this page. - public IReadOnlyList Value { get; } + public IList Value { get; } + /// The link to the next page of items. public Uri NextLink { get; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AzureResourceManagerDatabaseWatcherContext.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AzureResourceManagerDatabaseWatcherContext.cs index 44e400ea06a2..d28238ddd279 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AzureResourceManagerDatabaseWatcherContext.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AzureResourceManagerDatabaseWatcherContext.cs @@ -6,6 +6,7 @@ #nullable disable using System.ClientModel.Primitives; +using Azure; using Azure.ResourceManager.DatabaseWatcher.Models; using Azure.ResourceManager.Models; @@ -13,7 +14,7 @@ namespace Azure.ResourceManager.DatabaseWatcher { /// /// 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(AlertRuleResourceListResult))] [ModelReaderWriterBuildable(typeof(DatabaseWatcherAlertRuleData))] diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherAlertRuleProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherAlertRuleProperties.Serialization.cs index 3ae798adcae3..e1ae32410042 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherAlertRuleProperties.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherAlertRuleProperties.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - public partial class DatabaseWatcherAlertRuleProperties : IUtf8JsonSerializable, IJsonModel + /// The generic properties of the alert rule proxy resource. + public partial class DatabaseWatcherAlertRuleProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DatabaseWatcherAlertRuleProperties() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +35,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DatabaseWatcherAlertRuleProperties)} does not support writing '{format}' format."); } - writer.WritePropertyName("alertRuleResourceId"u8); writer.WriteStringValue(AlertRuleResourceId); writer.WritePropertyName("createdWithProperties"u8); @@ -49,15 +55,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WriteStringValue(AlertRuleTemplateId); writer.WritePropertyName("alertRuleTemplateVersion"u8); writer.WriteStringValue(AlertRuleTemplateVersion); - 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); } @@ -66,90 +72,96 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DatabaseWatcherAlertRuleProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherAlertRuleProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherAlertRuleProperties 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(DatabaseWatcherAlertRuleProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherAlertRuleProperties(document.RootElement, options); } - internal static DatabaseWatcherAlertRuleProperties DeserializeDatabaseWatcherAlertRuleProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DatabaseWatcherAlertRuleProperties DeserializeDatabaseWatcherAlertRuleProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } ResourceIdentifier alertRuleResourceId = default; AlertRuleCreationProperty createdWithProperties = default; - DateTimeOffset creationTime = default; + DateTimeOffset createdOn = default; DatabaseWatcherResourceProvisioningState? provisioningState = default; string alertRuleTemplateId = default; string alertRuleTemplateVersion = 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("alertRuleResourceId"u8)) + if (prop.NameEquals("alertRuleResourceId"u8)) { - alertRuleResourceId = new ResourceIdentifier(property.Value.GetString()); + alertRuleResourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("createdWithProperties"u8)) + if (prop.NameEquals("createdWithProperties"u8)) { - createdWithProperties = new AlertRuleCreationProperty(property.Value.GetString()); + createdWithProperties = new AlertRuleCreationProperty(prop.Value.GetString()); continue; } - if (property.NameEquals("creationTime"u8)) + if (prop.NameEquals("creationTime"u8)) { - creationTime = property.Value.GetDateTimeOffset("O"); + createdOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("provisioningState"u8)) + if (prop.NameEquals("provisioningState"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - provisioningState = new DatabaseWatcherResourceProvisioningState(property.Value.GetString()); + provisioningState = new DatabaseWatcherResourceProvisioningState(prop.Value.GetString()); continue; } - if (property.NameEquals("alertRuleTemplateId"u8)) + if (prop.NameEquals("alertRuleTemplateId"u8)) { - alertRuleTemplateId = property.Value.GetString(); + alertRuleTemplateId = prop.Value.GetString(); continue; } - if (property.NameEquals("alertRuleTemplateVersion"u8)) + if (prop.NameEquals("alertRuleTemplateVersion"u8)) { - alertRuleTemplateVersion = property.Value.GetString(); + alertRuleTemplateVersion = 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 DatabaseWatcherAlertRuleProperties( alertRuleResourceId, createdWithProperties, - creationTime, + createdOn, provisioningState, alertRuleTemplateId, alertRuleTemplateVersion, - 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": @@ -159,15 +171,20 @@ BinaryData IPersistableModel.Write(ModelRead } } - DatabaseWatcherAlertRuleProperties 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. + DatabaseWatcherAlertRuleProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherAlertRuleProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherAlertRuleProperties(document.RootElement, options); } default: @@ -175,6 +192,7 @@ DatabaseWatcherAlertRuleProperties IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherAlertRuleProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherAlertRuleProperties.cs index d61c6e5df6b4..7769474d53ee 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherAlertRuleProperties.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherAlertRuleProperties.cs @@ -8,43 +8,15 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { /// The generic properties of the alert rule proxy resource. public partial class DatabaseWatcherAlertRuleProperties { - /// - /// 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 resource ID of the alert rule resource. @@ -73,8 +45,8 @@ public DatabaseWatcherAlertRuleProperties(ResourceIdentifier alertRuleResourceId /// The provisioning state of the alert rule resource. /// The template ID associated with alert rule resource. /// The alert rule template version. - /// Keeps track of any properties unknown to the library. - internal DatabaseWatcherAlertRuleProperties(ResourceIdentifier alertRuleResourceId, AlertRuleCreationProperty createdWithProperties, DateTimeOffset createdOn, DatabaseWatcherResourceProvisioningState? provisioningState, string alertRuleTemplateId, string alertRuleTemplateVersion, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DatabaseWatcherAlertRuleProperties(ResourceIdentifier alertRuleResourceId, AlertRuleCreationProperty createdWithProperties, DateTimeOffset createdOn, DatabaseWatcherResourceProvisioningState? provisioningState, string alertRuleTemplateId, string alertRuleTemplateVersion, IDictionary additionalBinaryDataProperties) { AlertRuleResourceId = alertRuleResourceId; CreatedWithProperties = createdWithProperties; @@ -82,24 +54,24 @@ internal DatabaseWatcherAlertRuleProperties(ResourceIdentifier alertRuleResource ProvisioningState = provisioningState; AlertRuleTemplateId = alertRuleTemplateId; AlertRuleTemplateVersion = alertRuleTemplateVersion; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DatabaseWatcherAlertRuleProperties() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The resource ID of the alert rule resource. public ResourceIdentifier AlertRuleResourceId { get; set; } + /// The properties with which the alert rule resource was created. public AlertRuleCreationProperty CreatedWithProperties { get; set; } + /// The creation time of the alert rule resource. public DateTimeOffset CreatedOn { get; set; } + /// The provisioning state of the alert rule resource. public DatabaseWatcherResourceProvisioningState? ProvisioningState { get; } + /// The template ID associated with alert rule resource. public string AlertRuleTemplateId { get; set; } + /// The alert rule template version. public string AlertRuleTemplateVersion { get; set; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherDatastore.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherDatastore.Serialization.cs index 0557990e18bf..4ce78e7bc265 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherDatastore.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherDatastore.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - public partial class DatabaseWatcherDatastore : IUtf8JsonSerializable, IJsonModel + /// The properties of a data store. + public partial class DatabaseWatcherDatastore : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DatabaseWatcherDatastore() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +35,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead /// 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(DatabaseWatcherDatastore)} does not support writing '{format}' format."); } - if (Optional.IsDefined(AdxClusterResourceId)) { writer.WritePropertyName("adxClusterResourceId"u8); @@ -54,15 +60,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WriteStringValue(KustoManagementUri.AbsoluteUri); writer.WritePropertyName("kustoOfferingType"u8); writer.WriteStringValue(KustoOfferingType.ToString()); - 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 +77,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DatabaseWatcherDatastore IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherDatastore IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherDatastore 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(DatabaseWatcherDatastore)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherDatastore(document.RootElement, options); } - internal static DatabaseWatcherDatastore DeserializeDatabaseWatcherDatastore(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DatabaseWatcherDatastore DeserializeDatabaseWatcherDatastore(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -96,72 +107,73 @@ internal static DatabaseWatcherDatastore DeserializeDatabaseWatcherDatastore(Jso Uri kustoClusterUri = default; Uri kustoDataIngestionUri = default; string kustoDatabaseName = default; - Uri kustoManagementUrl = default; + Uri kustoManagementUri = default; KustoOfferingType kustoOfferingType = 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("adxClusterResourceId"u8)) + if (prop.NameEquals("adxClusterResourceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - adxClusterResourceId = new ResourceIdentifier(property.Value.GetString()); + adxClusterResourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("kustoClusterDisplayName"u8)) + if (prop.NameEquals("kustoClusterDisplayName"u8)) { - kustoClusterDisplayName = property.Value.GetString(); + kustoClusterDisplayName = prop.Value.GetString(); continue; } - if (property.NameEquals("kustoClusterUri"u8)) + if (prop.NameEquals("kustoClusterUri"u8)) { - kustoClusterUri = new Uri(property.Value.GetString()); + kustoClusterUri = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("kustoDataIngestionUri"u8)) + if (prop.NameEquals("kustoDataIngestionUri"u8)) { - kustoDataIngestionUri = new Uri(property.Value.GetString()); + kustoDataIngestionUri = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("kustoDatabaseName"u8)) + if (prop.NameEquals("kustoDatabaseName"u8)) { - kustoDatabaseName = property.Value.GetString(); + kustoDatabaseName = prop.Value.GetString(); continue; } - if (property.NameEquals("kustoManagementUrl"u8)) + if (prop.NameEquals("kustoManagementUrl"u8)) { - kustoManagementUrl = new Uri(property.Value.GetString()); + kustoManagementUri = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("kustoOfferingType"u8)) + if (prop.NameEquals("kustoOfferingType"u8)) { - kustoOfferingType = new KustoOfferingType(property.Value.GetString()); + kustoOfferingType = new KustoOfferingType(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 DatabaseWatcherDatastore( adxClusterResourceId, kustoClusterDisplayName, kustoClusterUri, kustoDataIngestionUri, kustoDatabaseName, - kustoManagementUrl, + kustoManagementUri, kustoOfferingType, - 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": @@ -171,15 +183,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp } } - DatabaseWatcherDatastore 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. + DatabaseWatcherDatastore IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherDatastore 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherDatastore(document.RootElement, options); } default: @@ -187,6 +204,7 @@ DatabaseWatcherDatastore IPersistableModel.Create(Bina } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherDatastore.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherDatastore.cs index afe036ba8e70..0e23fbb146cb 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherDatastore.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherDatastore.cs @@ -8,43 +8,15 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { /// The properties of a data store. public partial class DatabaseWatcherDatastore { - /// - /// 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 Kusto cluster URI. @@ -75,8 +47,8 @@ public DatabaseWatcherDatastore(Uri kustoClusterUri, Uri kustoDataIngestionUri, /// The name of a Kusto database. /// The Kusto management URL. /// The type of a Kusto offering. - /// Keeps track of any properties unknown to the library. - internal DatabaseWatcherDatastore(ResourceIdentifier adxClusterResourceId, string kustoClusterDisplayName, Uri kustoClusterUri, Uri kustoDataIngestionUri, string kustoDatabaseName, Uri kustoManagementUri, KustoOfferingType kustoOfferingType, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DatabaseWatcherDatastore(ResourceIdentifier adxClusterResourceId, string kustoClusterDisplayName, Uri kustoClusterUri, Uri kustoDataIngestionUri, string kustoDatabaseName, Uri kustoManagementUri, KustoOfferingType kustoOfferingType, IDictionary additionalBinaryDataProperties) { AdxClusterResourceId = adxClusterResourceId; KustoClusterDisplayName = kustoClusterDisplayName; @@ -85,26 +57,27 @@ internal DatabaseWatcherDatastore(ResourceIdentifier adxClusterResourceId, strin KustoDatabaseName = kustoDatabaseName; KustoManagementUri = kustoManagementUri; KustoOfferingType = kustoOfferingType; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DatabaseWatcherDatastore() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The Azure resource ID of an Azure Data Explorer cluster. public ResourceIdentifier AdxClusterResourceId { get; set; } + /// The Kusto cluster display name. public string KustoClusterDisplayName { get; set; } + /// The Kusto cluster URI. public Uri KustoClusterUri { get; set; } + /// The Kusto data ingestion URI. public Uri KustoDataIngestionUri { get; set; } + /// The name of a Kusto database. public string KustoDatabaseName { get; set; } + /// The Kusto management URL. public Uri KustoManagementUri { get; set; } + /// The type of a Kusto offering. public KustoOfferingType KustoOfferingType { get; set; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationIssue.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationIssue.Serialization.cs index eac63a248c28..a35634a55426 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationIssue.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationIssue.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - public partial class DatabaseWatcherHealthValidationIssue : IUtf8JsonSerializable, IJsonModel + /// The model of a health validation issue. + public partial class DatabaseWatcherHealthValidationIssue : 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 write /// 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(DatabaseWatcherHealthValidationIssue)} does not support writing '{format}' format."); } - if (options.Format != "W") { writer.WritePropertyName("errorCode"u8); @@ -69,15 +70,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("relatedResourceType"u8); writer.WriteStringValue(RelatedResourceType.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); } @@ -86,22 +87,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DatabaseWatcherHealthValidationIssue IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherHealthValidationIssue IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherHealthValidationIssue 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(DatabaseWatcherHealthValidationIssue)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherHealthValidationIssue(document.RootElement, options); } - internal static DatabaseWatcherHealthValidationIssue DeserializeDatabaseWatcherHealthValidationIssue(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DatabaseWatcherHealthValidationIssue DeserializeDatabaseWatcherHealthValidationIssue(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -110,81 +116,82 @@ internal static DatabaseWatcherHealthValidationIssue DeserializeDatabaseWatcherH string errorMessage = default; string additionalDetails = default; string recommendationMessage = default; - Uri recommendationUrl = default; + Uri recommendationUri = default; ResourceIdentifier relatedResourceId = default; ResourceType? relatedResourceType = 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("errorCode"u8)) + if (prop.NameEquals("errorCode"u8)) { - errorCode = property.Value.GetString(); + errorCode = prop.Value.GetString(); continue; } - if (property.NameEquals("errorMessage"u8)) + if (prop.NameEquals("errorMessage"u8)) { - errorMessage = property.Value.GetString(); + errorMessage = prop.Value.GetString(); continue; } - if (property.NameEquals("additionalDetails"u8)) + if (prop.NameEquals("additionalDetails"u8)) { - additionalDetails = property.Value.GetString(); + additionalDetails = prop.Value.GetString(); continue; } - if (property.NameEquals("recommendationMessage"u8)) + if (prop.NameEquals("recommendationMessage"u8)) { - recommendationMessage = property.Value.GetString(); + recommendationMessage = prop.Value.GetString(); continue; } - if (property.NameEquals("recommendationUrl"u8)) + if (prop.NameEquals("recommendationUrl"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - recommendationUrl = new Uri(property.Value.GetString()); + recommendationUri = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("relatedResourceId"u8)) + if (prop.NameEquals("relatedResourceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - relatedResourceId = new ResourceIdentifier(property.Value.GetString()); + relatedResourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("relatedResourceType"u8)) + if (prop.NameEquals("relatedResourceType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - relatedResourceType = new ResourceType(property.Value.GetString()); + relatedResourceType = new ResourceType(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 DatabaseWatcherHealthValidationIssue( errorCode, errorMessage, additionalDetails, recommendationMessage, - recommendationUrl, + recommendationUri, relatedResourceId, relatedResourceType, - 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": @@ -194,15 +201,20 @@ BinaryData IPersistableModel.Write(ModelRe } } - DatabaseWatcherHealthValidationIssue 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. + DatabaseWatcherHealthValidationIssue IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherHealthValidationIssue 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherHealthValidationIssue(document.RootElement, options); } default: @@ -210,6 +222,7 @@ DatabaseWatcherHealthValidationIssue IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationIssue.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationIssue.cs index 6dcf8e8a9468..7d09d8297f32 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationIssue.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationIssue.cs @@ -14,47 +14,12 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models /// The model of a health validation issue. public partial class DatabaseWatcherHealthValidationIssue { - /// - /// 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 error code of the issue. - /// The error message of the issue. - /// The recommendation for resolving the issue. - internal DatabaseWatcherHealthValidationIssue(string errorCode, string errorMessage, string recommendationMessage) + internal DatabaseWatcherHealthValidationIssue() { - ErrorCode = errorCode; - ErrorMessage = errorMessage; - RecommendationMessage = recommendationMessage; } /// Initializes a new instance of . @@ -65,8 +30,8 @@ internal DatabaseWatcherHealthValidationIssue(string errorCode, string errorMess /// The URL related to resolving the issue. /// The resource ID of the Azure resource related to the issue. /// The type of the Azure resource related to the issue. - /// Keeps track of any properties unknown to the library. - internal DatabaseWatcherHealthValidationIssue(string errorCode, string errorMessage, string additionalDetails, string recommendationMessage, Uri recommendationUri, ResourceIdentifier relatedResourceId, ResourceType? relatedResourceType, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DatabaseWatcherHealthValidationIssue(string errorCode, string errorMessage, string additionalDetails, string recommendationMessage, Uri recommendationUri, ResourceIdentifier relatedResourceId, ResourceType? relatedResourceType, IDictionary additionalBinaryDataProperties) { ErrorCode = errorCode; ErrorMessage = errorMessage; @@ -75,26 +40,27 @@ internal DatabaseWatcherHealthValidationIssue(string errorCode, string errorMess RecommendationUri = recommendationUri; RelatedResourceId = relatedResourceId; RelatedResourceType = relatedResourceType; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DatabaseWatcherHealthValidationIssue() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The error code of the issue. public string ErrorCode { get; } + /// The error message of the issue. public string ErrorMessage { get; } + /// The additional details for the issue. public string AdditionalDetails { get; } + /// The recommendation for resolving the issue. public string RecommendationMessage { get; } + /// The URL related to resolving the issue. public Uri RecommendationUri { get; } + /// The resource ID of the Azure resource related to the issue. public ResourceIdentifier RelatedResourceId { get; } + /// The type of the Azure resource related to the issue. public ResourceType? RelatedResourceType { get; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationProperties.Serialization.cs index 335b4557e176..846bd3b81bde 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationProperties.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - public partial class DatabaseWatcherHealthValidationProperties : IUtf8JsonSerializable, IJsonModel + /// The generic properties of the health validation resource. + public partial class DatabaseWatcherHealthValidationProperties : 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 /// 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(DatabaseWatcherHealthValidationProperties)} does not support writing '{format}' format."); } - if (options.Format != "W") { writer.WritePropertyName("startTime"u8); @@ -53,7 +53,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit { writer.WritePropertyName("issues"u8); writer.WriteStartArray(); - foreach (var item in Issues) + foreach (DatabaseWatcherHealthValidationIssue item in Issues) { writer.WriteObjectValue(item, options); } @@ -64,15 +64,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("provisioningState"u8); writer.WriteStringValue(ProvisioningState.Value.ToString()); } - 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); } @@ -81,88 +81,94 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DatabaseWatcherHealthValidationProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherHealthValidationProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherHealthValidationProperties 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(DatabaseWatcherHealthValidationProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherHealthValidationProperties(document.RootElement, options); } - internal static DatabaseWatcherHealthValidationProperties DeserializeDatabaseWatcherHealthValidationProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DatabaseWatcherHealthValidationProperties DeserializeDatabaseWatcherHealthValidationProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - DateTimeOffset startTime = default; - DateTimeOffset endTime = default; + DateTimeOffset startOn = default; + DateTimeOffset endOn = default; DatabaseWatcherHealthValidationStatus status = default; IReadOnlyList issues = default; DatabaseWatcherResourceProvisioningState? provisioningState = 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("startTime"u8)) + if (prop.NameEquals("startTime"u8)) { - startTime = property.Value.GetDateTimeOffset("O"); + startOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("endTime"u8)) + if (prop.NameEquals("endTime"u8)) { - endTime = property.Value.GetDateTimeOffset("O"); + endOn = prop.Value.GetDateTimeOffset("O"); continue; } - if (property.NameEquals("status"u8)) + if (prop.NameEquals("status"u8)) { - status = new DatabaseWatcherHealthValidationStatus(property.Value.GetString()); + status = new DatabaseWatcherHealthValidationStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("issues"u8)) + if (prop.NameEquals("issues"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DatabaseWatcherHealthValidationIssue.DeserializeDatabaseWatcherHealthValidationIssue(item, options)); } issues = array; continue; } - if (property.NameEquals("provisioningState"u8)) + if (prop.NameEquals("provisioningState"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - provisioningState = new DatabaseWatcherResourceProvisioningState(property.Value.GetString()); + provisioningState = new DatabaseWatcherResourceProvisioningState(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 DatabaseWatcherHealthValidationProperties( - startTime, - endTime, + startOn, + endOn, status, issues, provisioningState, - 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": @@ -172,15 +178,20 @@ BinaryData IPersistableModel.Write(Mo } } - DatabaseWatcherHealthValidationProperties 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. + DatabaseWatcherHealthValidationProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherHealthValidationProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherHealthValidationProperties(document.RootElement, options); } default: @@ -188,6 +199,7 @@ DatabaseWatcherHealthValidationProperties IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationProperties.cs index bb3744dd7147..6d1d52e48e25 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationProperties.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationProperties.cs @@ -7,56 +7,20 @@ using System; using System.Collections.Generic; -using System.Linq; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { /// The generic properties of the health validation resource. public partial class DatabaseWatcherHealthValidationProperties { - /// - /// 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 start time of health validation, in UTC. - /// The end time of health validation, in UTC. - /// The current health validation status. - /// The list of issues found by health validation. - internal DatabaseWatcherHealthValidationProperties(DateTimeOffset startOn, DateTimeOffset endOn, DatabaseWatcherHealthValidationStatus status, IEnumerable issues) + internal DatabaseWatcherHealthValidationProperties() { - StartOn = startOn; - EndOn = endOn; - Status = status; - Issues = issues.ToList(); + Issues = new ChangeTrackingList(); } /// Initializes a new instance of . @@ -65,30 +29,29 @@ internal DatabaseWatcherHealthValidationProperties(DateTimeOffset startOn, DateT /// The current health validation status. /// The list of issues found by health validation. /// The provisioning state of the health validation resource. - /// Keeps track of any properties unknown to the library. - internal DatabaseWatcherHealthValidationProperties(DateTimeOffset startOn, DateTimeOffset endOn, DatabaseWatcherHealthValidationStatus status, IReadOnlyList issues, DatabaseWatcherResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DatabaseWatcherHealthValidationProperties(DateTimeOffset startOn, DateTimeOffset endOn, DatabaseWatcherHealthValidationStatus status, IReadOnlyList issues, DatabaseWatcherResourceProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) { StartOn = startOn; EndOn = endOn; Status = status; Issues = issues; ProvisioningState = provisioningState; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DatabaseWatcherHealthValidationProperties() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The start time of health validation, in UTC. public DateTimeOffset StartOn { get; } + /// The end time of health validation, in UTC. public DateTimeOffset EndOn { get; } + /// The current health validation status. public DatabaseWatcherHealthValidationStatus Status { get; } + /// The list of issues found by health validation. public IReadOnlyList Issues { get; } + /// The provisioning state of the health validation resource. public DatabaseWatcherResourceProvisioningState? ProvisioningState { get; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationStatus.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationStatus.cs index 293207dda48b..11a64db509f8 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationStatus.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherHealthValidationStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { @@ -14,50 +15,77 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models public readonly partial struct DatabaseWatcherHealthValidationStatus : IEquatable { private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public DatabaseWatcherHealthValidationStatus(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - + /// Health validation has not started. private const string NotStartedValue = "NotStarted"; + /// Health validation is running. private const string RunningValue = "Running"; + /// Health validation completed successfully. private const string SucceededValue = "Succeeded"; + /// Health validation failed. private const string FailedValue = "Failed"; + /// Health validation was canceled. private const string CanceledValue = "Canceled"; + /// Health validation timed out. private const string TimedOutValue = "TimedOut"; + /// Initializes a new instance of . + /// The value. + /// is null. + public DatabaseWatcherHealthValidationStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + /// Health validation has not started. public static DatabaseWatcherHealthValidationStatus NotStarted { get; } = new DatabaseWatcherHealthValidationStatus(NotStartedValue); + /// Health validation is running. public static DatabaseWatcherHealthValidationStatus Running { get; } = new DatabaseWatcherHealthValidationStatus(RunningValue); + /// Health validation completed successfully. public static DatabaseWatcherHealthValidationStatus Succeeded { get; } = new DatabaseWatcherHealthValidationStatus(SucceededValue); + /// Health validation failed. public static DatabaseWatcherHealthValidationStatus Failed { get; } = new DatabaseWatcherHealthValidationStatus(FailedValue); + /// Health validation was canceled. public static DatabaseWatcherHealthValidationStatus Canceled { get; } = new DatabaseWatcherHealthValidationStatus(CanceledValue); + /// Health validation timed out. public static DatabaseWatcherHealthValidationStatus TimedOut { get; } = new DatabaseWatcherHealthValidationStatus(TimedOutValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DatabaseWatcherHealthValidationStatus left, DatabaseWatcherHealthValidationStatus right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DatabaseWatcherHealthValidationStatus left, DatabaseWatcherHealthValidationStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DatabaseWatcherHealthValidationStatus(string value) => new DatabaseWatcherHealthValidationStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DatabaseWatcherHealthValidationStatus?(string value) => value == null ? null : new DatabaseWatcherHealthValidationStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DatabaseWatcherHealthValidationStatus other && Equals(other); - /// + + /// public bool Equals(DatabaseWatcherHealthValidationStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherPatch.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherPatch.Serialization.cs index 62ba242e8aa3..9be355981f40 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherPatch.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherPatch.Serialization.cs @@ -11,14 +11,16 @@ using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DatabaseWatcher.Models { - public partial class DatabaseWatcherPatch : IUtf8JsonSerializable, IJsonModel + /// The type used for update operations of the Watcher. + public partial class DatabaseWatcherPatch : 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, ModelReaderWr /// 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(DatabaseWatcherPatch)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"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(); @@ -57,15 +63,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties, options); } - 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); } @@ -74,22 +80,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DatabaseWatcherPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherPatch 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(DatabaseWatcherPatch)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherPatch(document.RootElement, options); } - internal static DatabaseWatcherPatch DeserializeDatabaseWatcherPatch(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DatabaseWatcherPatch DeserializeDatabaseWatcherPatch(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -97,55 +108,63 @@ internal static DatabaseWatcherPatch DeserializeDatabaseWatcherPatch(JsonElement ManagedServiceIdentity identity = default; IDictionary tags = default; DatabaseWatcherUpdateProperties properties = 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("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())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDatabaseWatcherContext.Default); + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerDatabaseWatcherContext.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("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = DatabaseWatcherUpdateProperties.DeserializeDatabaseWatcherUpdateProperties(property.Value, options); + properties = DatabaseWatcherUpdateProperties.DeserializeDatabaseWatcherUpdateProperties(prop.Value, options); 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 DatabaseWatcherPatch(identity, tags ?? new ChangeTrackingDictionary(), properties, serializedAdditionalRawData); + return new DatabaseWatcherPatch(identity, tags ?? new ChangeTrackingDictionary(), properties, 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": @@ -155,15 +174,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - DatabaseWatcherPatch 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. + DatabaseWatcherPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherPatch 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherPatch(document.RootElement, options); } default: @@ -171,6 +195,19 @@ DatabaseWatcherPatch IPersistableModel.Create(BinaryData d } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(DatabaseWatcherPatch databaseWatcherPatch) + { + if (databaseWatcherPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(databaseWatcherPatch, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherPatch.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherPatch.cs index 20f5832fb4b9..a787d58ffbb9 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherPatch.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherPatch.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.DatabaseWatcher; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.DatabaseWatcher.Models @@ -14,37 +15,8 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models /// The type used for update operations of the Watcher. public partial class DatabaseWatcherPatch { - /// - /// 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 DatabaseWatcherPatch() @@ -56,16 +28,21 @@ public DatabaseWatcherPatch() /// The managed service identities assigned to this resource. /// Resource tags. /// The resource-specific properties for this resource. - /// Keeps track of any properties unknown to the library. - internal DatabaseWatcherPatch(ManagedServiceIdentity identity, IDictionary tags, DatabaseWatcherUpdateProperties properties, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DatabaseWatcherPatch(ManagedServiceIdentity identity, IDictionary tags, DatabaseWatcherUpdateProperties properties, IDictionary additionalBinaryDataProperties) { Identity = identity; Tags = tags; Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } + + /// The managed service identities assigned to this resource. + public ManagedServiceIdentity Identity { get; set; } + /// Resource tags. public IDictionary Tags { get; } + /// The resource-specific properties for this resource. public DatabaseWatcherUpdateProperties Properties { get; set; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherProperties.Serialization.cs index e68e88e96bdf..ac9910494b5d 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherProperties.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherProperties.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - public partial class DatabaseWatcherProperties : IUtf8JsonSerializable, IJsonModel + /// The RP specific properties of the resource. + public partial class DatabaseWatcherProperties : 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, ModelRea /// 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(DatabaseWatcherProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Datastore)) { writer.WritePropertyName("datastore"u8); @@ -54,15 +55,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("defaultAlertRuleIdentityResourceId"u8); writer.WriteStringValue(DefaultAlertRuleIdentityResourceId); } - 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 +72,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DatabaseWatcherProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherProperties 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(DatabaseWatcherProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherProperties(document.RootElement, options); } - internal static DatabaseWatcherProperties DeserializeDatabaseWatcherProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DatabaseWatcherProperties DeserializeDatabaseWatcherProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -95,59 +101,60 @@ internal static DatabaseWatcherProperties DeserializeDatabaseWatcherProperties(J DatabaseWatcherStatus? status = default; DatabaseWatcherProvisioningState? provisioningState = default; ResourceIdentifier defaultAlertRuleIdentityResourceId = 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("datastore"u8)) + if (prop.NameEquals("datastore"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - datastore = DatabaseWatcherDatastore.DeserializeDatabaseWatcherDatastore(property.Value, options); + datastore = DatabaseWatcherDatastore.DeserializeDatabaseWatcherDatastore(prop.Value, options); continue; } - if (property.NameEquals("status"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - status = new DatabaseWatcherStatus(property.Value.GetString()); + status = new DatabaseWatcherStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("provisioningState"u8)) + if (prop.NameEquals("provisioningState"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - provisioningState = new DatabaseWatcherProvisioningState(property.Value.GetString()); + provisioningState = new DatabaseWatcherProvisioningState(prop.Value.GetString()); continue; } - if (property.NameEquals("defaultAlertRuleIdentityResourceId"u8)) + if (prop.NameEquals("defaultAlertRuleIdentityResourceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - defaultAlertRuleIdentityResourceId = new ResourceIdentifier(property.Value.GetString()); + defaultAlertRuleIdentityResourceId = new ResourceIdentifier(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 DatabaseWatcherProperties(datastore, status, provisioningState, defaultAlertRuleIdentityResourceId, serializedAdditionalRawData); + return new DatabaseWatcherProperties(datastore, status, provisioningState, defaultAlertRuleIdentityResourceId, 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": @@ -157,15 +164,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterO } } - DatabaseWatcherProperties 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. + DatabaseWatcherProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherProperties(document.RootElement, options); } default: @@ -173,6 +185,7 @@ DatabaseWatcherProperties IPersistableModel.Create(Bi } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherProperties.cs index ea57e69ab537..eb2c686dac26 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherProperties.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherProperties.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models /// The RP specific properties of the resource. public partial class DatabaseWatcherProperties { - /// - /// 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 DatabaseWatcherProperties() @@ -56,22 +27,25 @@ public DatabaseWatcherProperties() /// The monitoring collection status of the watcher. /// The provisioning state of the resource watcher. /// The resource ID of a user-assigned managed identity that will be assigned to a new alert rule. - /// Keeps track of any properties unknown to the library. - internal DatabaseWatcherProperties(DatabaseWatcherDatastore datastore, DatabaseWatcherStatus? status, DatabaseWatcherProvisioningState? provisioningState, ResourceIdentifier defaultAlertRuleIdentityResourceId, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DatabaseWatcherProperties(DatabaseWatcherDatastore datastore, DatabaseWatcherStatus? status, DatabaseWatcherProvisioningState? provisioningState, ResourceIdentifier defaultAlertRuleIdentityResourceId, IDictionary additionalBinaryDataProperties) { Datastore = datastore; Status = status; ProvisioningState = provisioningState; DefaultAlertRuleIdentityResourceId = defaultAlertRuleIdentityResourceId; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The data store for collected monitoring data. public DatabaseWatcherDatastore Datastore { get; set; } + /// The monitoring collection status of the watcher. public DatabaseWatcherStatus? Status { get; } + /// The provisioning state of the resource watcher. public DatabaseWatcherProvisioningState? ProvisioningState { get; } + /// The resource ID of a user-assigned managed identity that will be assigned to a new alert rule. public ResourceIdentifier DefaultAlertRuleIdentityResourceId { get; set; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherProvisioningState.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherProvisioningState.cs index 1d26cbf74b16..88625954ef67 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherProvisioningState.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherProvisioningState.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { @@ -14,41 +15,62 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models public readonly partial struct DatabaseWatcherProvisioningState : IEquatable { private readonly string _value; + /// Resource has been created. + private const string SucceededValue = "Succeeded"; + /// Resource creation failed. + private const string FailedValue = "Failed"; + /// Resource creation was canceled. + private const string CanceledValue = "Canceled"; /// Initializes a new instance of . + /// The value. /// is null. public DatabaseWatcherProvisioningState(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SucceededValue = "Succeeded"; - private const string FailedValue = "Failed"; - private const string CanceledValue = "Canceled"; + _value = value; + } /// Resource has been created. public static DatabaseWatcherProvisioningState Succeeded { get; } = new DatabaseWatcherProvisioningState(SucceededValue); + /// Resource creation failed. public static DatabaseWatcherProvisioningState Failed { get; } = new DatabaseWatcherProvisioningState(FailedValue); + /// Resource creation was canceled. public static DatabaseWatcherProvisioningState Canceled { get; } = new DatabaseWatcherProvisioningState(CanceledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DatabaseWatcherProvisioningState left, DatabaseWatcherProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DatabaseWatcherProvisioningState left, DatabaseWatcherProvisioningState right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DatabaseWatcherProvisioningState(string value) => new DatabaseWatcherProvisioningState(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DatabaseWatcherProvisioningState?(string value) => value == null ? null : new DatabaseWatcherProvisioningState(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DatabaseWatcherProvisioningState other && Equals(other); - /// + + /// public bool Equals(DatabaseWatcherProvisioningState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherResourceProvisioningState.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherResourceProvisioningState.cs index d9eb506a2833..494b61991b51 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherResourceProvisioningState.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherResourceProvisioningState.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { @@ -14,41 +15,62 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models public readonly partial struct DatabaseWatcherResourceProvisioningState : IEquatable { private readonly string _value; + /// Resource has been created. + private const string SucceededValue = "Succeeded"; + /// Resource creation failed. + private const string FailedValue = "Failed"; + /// Resource creation was canceled. + private const string CanceledValue = "Canceled"; /// Initializes a new instance of . + /// The value. /// is null. public DatabaseWatcherResourceProvisioningState(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SucceededValue = "Succeeded"; - private const string FailedValue = "Failed"; - private const string CanceledValue = "Canceled"; + _value = value; + } /// Resource has been created. public static DatabaseWatcherResourceProvisioningState Succeeded { get; } = new DatabaseWatcherResourceProvisioningState(SucceededValue); + /// Resource creation failed. public static DatabaseWatcherResourceProvisioningState Failed { get; } = new DatabaseWatcherResourceProvisioningState(FailedValue); + /// Resource creation was canceled. public static DatabaseWatcherResourceProvisioningState Canceled { get; } = new DatabaseWatcherResourceProvisioningState(CanceledValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DatabaseWatcherResourceProvisioningState left, DatabaseWatcherResourceProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DatabaseWatcherResourceProvisioningState left, DatabaseWatcherResourceProvisioningState right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DatabaseWatcherResourceProvisioningState(string value) => new DatabaseWatcherResourceProvisioningState(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DatabaseWatcherResourceProvisioningState?(string value) => value == null ? null : new DatabaseWatcherResourceProvisioningState(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DatabaseWatcherResourceProvisioningState other && Equals(other); - /// + + /// public bool Equals(DatabaseWatcherResourceProvisioningState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherSharedPrivateLinkResourceProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherSharedPrivateLinkResourceProperties.Serialization.cs index 701f486154f6..ef61e7a7d150 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherSharedPrivateLinkResourceProperties.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherSharedPrivateLinkResourceProperties.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - public partial class DatabaseWatcherSharedPrivateLinkResourceProperties : IUtf8JsonSerializable, IJsonModel + /// The generic properties of a Shared Private Link resource. + public partial class DatabaseWatcherSharedPrivateLinkResourceProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DatabaseWatcherSharedPrivateLinkResourceProperties() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +35,11 @@ void IJsonModel.Write(Utf8Js /// 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(DatabaseWatcherSharedPrivateLinkResourceProperties)} does not support writing '{format}' format."); } - writer.WritePropertyName("privateLinkResourceId"u8); writer.WriteStringValue(PrivateLinkResourceId); writer.WritePropertyName("groupId"u8); @@ -55,15 +61,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("provisioningState"u8); writer.WriteStringValue(ProvisioningState.Value.ToString()); } - 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); } @@ -72,22 +78,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DatabaseWatcherSharedPrivateLinkResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherSharedPrivateLinkResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherSharedPrivateLinkResourceProperties 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(DatabaseWatcherSharedPrivateLinkResourceProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherSharedPrivateLinkResourceProperties(document.RootElement, options); } - internal static DatabaseWatcherSharedPrivateLinkResourceProperties DeserializeDatabaseWatcherSharedPrivateLinkResourceProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DatabaseWatcherSharedPrivateLinkResourceProperties DeserializeDatabaseWatcherSharedPrivateLinkResourceProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -98,54 +109,52 @@ internal static DatabaseWatcherSharedPrivateLinkResourceProperties DeserializeDa string dnsZone = default; DatabaseWatcherSharedPrivateLinkResourceStatus? status = default; DatabaseWatcherResourceProvisioningState? provisioningState = 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("privateLinkResourceId"u8)) + if (prop.NameEquals("privateLinkResourceId"u8)) { - privateLinkResourceId = new ResourceIdentifier(property.Value.GetString()); + privateLinkResourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("groupId"u8)) + if (prop.NameEquals("groupId"u8)) { - groupId = property.Value.GetString(); + groupId = prop.Value.GetString(); continue; } - if (property.NameEquals("requestMessage"u8)) + if (prop.NameEquals("requestMessage"u8)) { - requestMessage = property.Value.GetString(); + requestMessage = prop.Value.GetString(); continue; } - if (property.NameEquals("dnsZone"u8)) + if (prop.NameEquals("dnsZone"u8)) { - dnsZone = property.Value.GetString(); + dnsZone = prop.Value.GetString(); continue; } - if (property.NameEquals("status"u8)) + if (prop.NameEquals("status"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - status = new DatabaseWatcherSharedPrivateLinkResourceStatus(property.Value.GetString()); + status = new DatabaseWatcherSharedPrivateLinkResourceStatus(prop.Value.GetString()); continue; } - if (property.NameEquals("provisioningState"u8)) + if (prop.NameEquals("provisioningState"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - provisioningState = new DatabaseWatcherResourceProvisioningState(property.Value.GetString()); + provisioningState = new DatabaseWatcherResourceProvisioningState(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 DatabaseWatcherSharedPrivateLinkResourceProperties( privateLinkResourceId, groupId, @@ -153,13 +162,16 @@ internal static DatabaseWatcherSharedPrivateLinkResourceProperties DeserializeDa dnsZone, status, provisioningState, - 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": @@ -169,15 +181,20 @@ BinaryData IPersistableModel } } - DatabaseWatcherSharedPrivateLinkResourceProperties 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. + DatabaseWatcherSharedPrivateLinkResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherSharedPrivateLinkResourceProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherSharedPrivateLinkResourceProperties(document.RootElement, options); } default: @@ -185,6 +202,7 @@ DatabaseWatcherSharedPrivateLinkResourceProperties IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherSharedPrivateLinkResourceProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherSharedPrivateLinkResourceProperties.cs index bacf7a0f69a5..4d2d62bddb63 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherSharedPrivateLinkResourceProperties.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherSharedPrivateLinkResourceProperties.cs @@ -8,43 +8,15 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { /// The generic properties of a Shared Private Link resource. public partial class DatabaseWatcherSharedPrivateLinkResourceProperties { - /// - /// 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 resource ID of the resource the shared private link resource is for. @@ -69,8 +41,8 @@ public DatabaseWatcherSharedPrivateLinkResourceProperties(ResourceIdentifier pri /// The DNS zone segment to be included in the DNS name of the shared private link. Value is required for Azure Data Explorer clusters and SQL managed instances, and must be omitted for SQL logical servers and key vaults. The value is the second segment of the host FQDN name of the resource that the shared private link resource is for. For example: if the host name is 'adx-cluster-21187695.eastus.kusto.windows.net', then the value is 'eastus'; if the host name is 'sql-mi-23961134.767d5869f605.database.windows.net', then the value is '767d5869f605'. /// Status of the shared private link resource. Can be Pending, Approved, Rejected or Disconnected. /// The provisioning state of the resource. - /// Keeps track of any properties unknown to the library. - internal DatabaseWatcherSharedPrivateLinkResourceProperties(ResourceIdentifier privateLinkResourceId, string groupId, string requestMessage, string dnsZone, DatabaseWatcherSharedPrivateLinkResourceStatus? status, DatabaseWatcherResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DatabaseWatcherSharedPrivateLinkResourceProperties(ResourceIdentifier privateLinkResourceId, string groupId, string requestMessage, string dnsZone, DatabaseWatcherSharedPrivateLinkResourceStatus? status, DatabaseWatcherResourceProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) { PrivateLinkResourceId = privateLinkResourceId; GroupId = groupId; @@ -78,24 +50,24 @@ internal DatabaseWatcherSharedPrivateLinkResourceProperties(ResourceIdentifier p DnsZone = dnsZone; Status = status; ProvisioningState = provisioningState; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DatabaseWatcherSharedPrivateLinkResourceProperties() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The resource ID of the resource the shared private link resource is for. public ResourceIdentifier PrivateLinkResourceId { get; set; } + /// The group id from the provider of resource the shared private link resource is for. public string GroupId { get; set; } + /// The request message for requesting approval of the shared private link resource. public string RequestMessage { get; set; } + /// The DNS zone segment to be included in the DNS name of the shared private link. Value is required for Azure Data Explorer clusters and SQL managed instances, and must be omitted for SQL logical servers and key vaults. The value is the second segment of the host FQDN name of the resource that the shared private link resource is for. For example: if the host name is 'adx-cluster-21187695.eastus.kusto.windows.net', then the value is 'eastus'; if the host name is 'sql-mi-23961134.767d5869f605.database.windows.net', then the value is '767d5869f605'. public string DnsZone { get; set; } + /// Status of the shared private link resource. Can be Pending, Approved, Rejected or Disconnected. public DatabaseWatcherSharedPrivateLinkResourceStatus? Status { get; } + /// The provisioning state of the resource. public DatabaseWatcherResourceProvisioningState? ProvisioningState { get; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherSharedPrivateLinkResourceStatus.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherSharedPrivateLinkResourceStatus.cs index 332cbf5adf5d..ff3968e2ba24 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherSharedPrivateLinkResourceStatus.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherSharedPrivateLinkResourceStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { @@ -14,44 +15,67 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models public readonly partial struct DatabaseWatcherSharedPrivateLinkResourceStatus : IEquatable { private readonly string _value; + /// The shared private link connection request was not yet authorized by the resource owner. + private const string PendingValue = "Pending"; + /// The shared private link connection request was approved by the resource owner. + private const string ApprovedValue = "Approved"; + /// The shared private link connection request was rejected by the resource owner. + private const string RejectedValue = "Rejected"; + /// The shared private link connection request was disconnected by the resource owner. + private const string DisconnectedValue = "Disconnected"; /// Initializes a new instance of . + /// The value. /// is null. public DatabaseWatcherSharedPrivateLinkResourceStatus(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string PendingValue = "Pending"; - private const string ApprovedValue = "Approved"; - private const string RejectedValue = "Rejected"; - private const string DisconnectedValue = "Disconnected"; + _value = value; + } /// The shared private link connection request was not yet authorized by the resource owner. public static DatabaseWatcherSharedPrivateLinkResourceStatus Pending { get; } = new DatabaseWatcherSharedPrivateLinkResourceStatus(PendingValue); + /// The shared private link connection request was approved by the resource owner. public static DatabaseWatcherSharedPrivateLinkResourceStatus Approved { get; } = new DatabaseWatcherSharedPrivateLinkResourceStatus(ApprovedValue); + /// The shared private link connection request was rejected by the resource owner. public static DatabaseWatcherSharedPrivateLinkResourceStatus Rejected { get; } = new DatabaseWatcherSharedPrivateLinkResourceStatus(RejectedValue); + /// The shared private link connection request was disconnected by the resource owner. public static DatabaseWatcherSharedPrivateLinkResourceStatus Disconnected { get; } = new DatabaseWatcherSharedPrivateLinkResourceStatus(DisconnectedValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DatabaseWatcherSharedPrivateLinkResourceStatus left, DatabaseWatcherSharedPrivateLinkResourceStatus right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DatabaseWatcherSharedPrivateLinkResourceStatus left, DatabaseWatcherSharedPrivateLinkResourceStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DatabaseWatcherSharedPrivateLinkResourceStatus(string value) => new DatabaseWatcherSharedPrivateLinkResourceStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DatabaseWatcherSharedPrivateLinkResourceStatus?(string value) => value == null ? null : new DatabaseWatcherSharedPrivateLinkResourceStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DatabaseWatcherSharedPrivateLinkResourceStatus other && Equals(other); - /// + + /// public bool Equals(DatabaseWatcherSharedPrivateLinkResourceStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherStatus.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherStatus.cs index 778cf0daceb8..894b65542b71 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherStatus.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherStatus.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { @@ -14,47 +15,72 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models public readonly partial struct DatabaseWatcherStatus : IEquatable { private readonly string _value; + /// Denotes the watcher is in a starting state. + private const string StartingValue = "Starting"; + /// Denotes the watcher is in a running state. + private const string RunningValue = "Running"; + /// Denotes the watcher is in a stopping state. + private const string StoppingValue = "Stopping"; + /// Denotes the watcher is in a stopped state. + private const string StoppedValue = "Stopped"; + /// Denotes the watcher is in a deleting state. + private const string DeletingValue = "Deleting"; /// Initializes a new instance of . + /// The value. /// is null. public DatabaseWatcherStatus(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string StartingValue = "Starting"; - private const string RunningValue = "Running"; - private const string StoppingValue = "Stopping"; - private const string StoppedValue = "Stopped"; - private const string DeletingValue = "Deleting"; + _value = value; + } /// Denotes the watcher is in a starting state. public static DatabaseWatcherStatus Starting { get; } = new DatabaseWatcherStatus(StartingValue); + /// Denotes the watcher is in a running state. public static DatabaseWatcherStatus Running { get; } = new DatabaseWatcherStatus(RunningValue); + /// Denotes the watcher is in a stopping state. public static DatabaseWatcherStatus Stopping { get; } = new DatabaseWatcherStatus(StoppingValue); + /// Denotes the watcher is in a stopped state. public static DatabaseWatcherStatus Stopped { get; } = new DatabaseWatcherStatus(StoppedValue); + /// Denotes the watcher is in a deleting state. public static DatabaseWatcherStatus Deleting { get; } = new DatabaseWatcherStatus(DeletingValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DatabaseWatcherStatus left, DatabaseWatcherStatus right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DatabaseWatcherStatus left, DatabaseWatcherStatus right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DatabaseWatcherStatus(string value) => new DatabaseWatcherStatus(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator DatabaseWatcherStatus?(string value) => value == null ? null : new DatabaseWatcherStatus(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DatabaseWatcherStatus other && Equals(other); - /// + + /// public bool Equals(DatabaseWatcherStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherTargetProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherTargetProperties.Serialization.cs index 52b2e40fd703..92835cd45a14 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherTargetProperties.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherTargetProperties.Serialization.cs @@ -8,15 +8,24 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { + /// + /// The generic properties of a target. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// [PersistableModelProxy(typeof(UnknownDatabaseWatcherTargetProperties))] - public partial class DatabaseWatcherTargetProperties : IUtf8JsonSerializable, IJsonModel + public abstract partial class DatabaseWatcherTargetProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal DatabaseWatcherTargetProperties() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +37,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo /// 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(DatabaseWatcherTargetProperties)} does not support writing '{format}' format."); } - writer.WritePropertyName("targetType"u8); writer.WriteStringValue(TargetType); writer.WritePropertyName("targetAuthenticationType"u8); @@ -50,15 +58,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("provisioningState"u8); writer.WriteStringValue(ProvisioningState.Value.ToString()); } - 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); } @@ -67,42 +75,53 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DatabaseWatcherTargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherTargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherTargetProperties 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(DatabaseWatcherTargetProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherTargetProperties(document.RootElement, options); } - internal static DatabaseWatcherTargetProperties DeserializeDatabaseWatcherTargetProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DatabaseWatcherTargetProperties DeserializeDatabaseWatcherTargetProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - if (element.TryGetProperty("targetType", out JsonElement discriminator)) + if (element.TryGetProperty("targetType"u8, out JsonElement discriminator)) { switch (discriminator.GetString()) { - case "SqlDb": return SqlDBSingleDatabaseTargetProperties.DeserializeSqlDBSingleDatabaseTargetProperties(element, options); - case "SqlEp": return SqlDBElasticPoolTargetProperties.DeserializeSqlDBElasticPoolTargetProperties(element, options); - case "SqlMi": return SqlMITargetProperties.DeserializeSqlMITargetProperties(element, options); + case "SqlDb": + return SqlDBSingleDatabaseTargetProperties.DeserializeSqlDBSingleDatabaseTargetProperties(element, options); + case "SqlEp": + return SqlDBElasticPoolTargetProperties.DeserializeSqlDBElasticPoolTargetProperties(element, options); + case "SqlMi": + return SqlMITargetProperties.DeserializeSqlMITargetProperties(element, options); } } return UnknownDatabaseWatcherTargetProperties.DeserializeUnknownDatabaseWatcherTargetProperties(element, options); } - 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": @@ -112,15 +131,20 @@ BinaryData IPersistableModel.Write(ModelReaderW } } - DatabaseWatcherTargetProperties 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. + DatabaseWatcherTargetProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherTargetProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherTargetProperties(document.RootElement, options); } default: @@ -128,6 +152,7 @@ DatabaseWatcherTargetProperties IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherTargetProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherTargetProperties.cs index e6142849b1c4..749bb2f97348 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherTargetProperties.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherTargetProperties.cs @@ -12,51 +12,20 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models { /// /// The generic properties of a target. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . /// public abstract partial class DatabaseWatcherTargetProperties { - /// - /// 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 protected IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . + /// Discriminator property for DatabaseWatcherTargetProperties. /// The type of authentication to use when connecting to a target. /// The FQDN host name of the server to use in the connection string when connecting to a target. For example, for an Azure SQL logical server in the Azure commercial cloud, the value might be 'sql-logical-server-22092780.database.windows.net'; for an Azure SQL managed instance in the Azure commercial cloud, the value might be 'sql-mi-39441134.767d5869f605.database.windows.net'. Port number and instance name must be specified separately. - /// is null. - protected DatabaseWatcherTargetProperties(TargetAuthenticationType targetAuthenticationType, string connectionServerName) + private protected DatabaseWatcherTargetProperties(string targetType, TargetAuthenticationType targetAuthenticationType, string connectionServerName) { - Argument.AssertNotNull(connectionServerName, nameof(connectionServerName)); - + TargetType = targetType; TargetAuthenticationType = targetAuthenticationType; ConnectionServerName = connectionServerName; } @@ -67,30 +36,29 @@ protected DatabaseWatcherTargetProperties(TargetAuthenticationType targetAuthent /// To use SQL authentication when connecting to targets, specify the vault where the login name and password secrets are stored. /// The FQDN host name of the server to use in the connection string when connecting to a target. For example, for an Azure SQL logical server in the Azure commercial cloud, the value might be 'sql-logical-server-22092780.database.windows.net'; for an Azure SQL managed instance in the Azure commercial cloud, the value might be 'sql-mi-39441134.767d5869f605.database.windows.net'. Port number and instance name must be specified separately. /// The provisioning state of the resource. - /// Keeps track of any properties unknown to the library. - internal DatabaseWatcherTargetProperties(string targetType, TargetAuthenticationType targetAuthenticationType, TargetAuthenticationVaultSecret targetVault, string connectionServerName, DatabaseWatcherResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DatabaseWatcherTargetProperties(string targetType, TargetAuthenticationType targetAuthenticationType, TargetAuthenticationVaultSecret targetVault, string connectionServerName, DatabaseWatcherResourceProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) { TargetType = targetType; TargetAuthenticationType = targetAuthenticationType; TargetVault = targetVault; ConnectionServerName = connectionServerName; ProvisioningState = provisioningState; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal DatabaseWatcherTargetProperties() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Discriminator property for DatabaseWatcherTargetProperties. internal string TargetType { get; set; } + /// The type of authentication to use when connecting to a target. public TargetAuthenticationType TargetAuthenticationType { get; set; } + /// To use SQL authentication when connecting to targets, specify the vault where the login name and password secrets are stored. public TargetAuthenticationVaultSecret TargetVault { get; set; } + /// The FQDN host name of the server to use in the connection string when connecting to a target. For example, for an Azure SQL logical server in the Azure commercial cloud, the value might be 'sql-logical-server-22092780.database.windows.net'; for an Azure SQL managed instance in the Azure commercial cloud, the value might be 'sql-mi-39441134.767d5869f605.database.windows.net'. Port number and instance name must be specified separately. public string ConnectionServerName { get; set; } + /// The provisioning state of the resource. public DatabaseWatcherResourceProvisioningState? ProvisioningState { get; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherUpdateProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherUpdateProperties.Serialization.cs index c6caa5b195b4..56f6abd4f76f 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherUpdateProperties.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherUpdateProperties.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - public partial class DatabaseWatcherUpdateProperties : IUtf8JsonSerializable, IJsonModel + /// The updatable properties of the Watcher. + public partial class DatabaseWatcherUpdateProperties : 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, Mo /// 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(DatabaseWatcherUpdateProperties)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Datastore)) { writer.WritePropertyName("datastore"u8); @@ -44,15 +45,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("defaultAlertRuleIdentityResourceId"u8); writer.WriteStringValue(DefaultAlertRuleIdentityResourceId); } - 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,63 +62,69 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - DatabaseWatcherUpdateProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherUpdateProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherUpdateProperties 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(DatabaseWatcherUpdateProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherUpdateProperties(document.RootElement, options); } - internal static DatabaseWatcherUpdateProperties DeserializeDatabaseWatcherUpdateProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DatabaseWatcherUpdateProperties DeserializeDatabaseWatcherUpdateProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } DatabaseWatcherDatastore datastore = default; ResourceIdentifier defaultAlertRuleIdentityResourceId = 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("datastore"u8)) + if (prop.NameEquals("datastore"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - datastore = DatabaseWatcherDatastore.DeserializeDatabaseWatcherDatastore(property.Value, options); + datastore = DatabaseWatcherDatastore.DeserializeDatabaseWatcherDatastore(prop.Value, options); continue; } - if (property.NameEquals("defaultAlertRuleIdentityResourceId"u8)) + if (prop.NameEquals("defaultAlertRuleIdentityResourceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - defaultAlertRuleIdentityResourceId = new ResourceIdentifier(property.Value.GetString()); + defaultAlertRuleIdentityResourceId = new ResourceIdentifier(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 DatabaseWatcherUpdateProperties(datastore, defaultAlertRuleIdentityResourceId, serializedAdditionalRawData); + return new DatabaseWatcherUpdateProperties(datastore, defaultAlertRuleIdentityResourceId, 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": @@ -127,15 +134,20 @@ BinaryData IPersistableModel.Write(ModelReaderW } } - DatabaseWatcherUpdateProperties 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. + DatabaseWatcherUpdateProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DatabaseWatcherUpdateProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherUpdateProperties(document.RootElement, options); } default: @@ -143,6 +155,7 @@ DatabaseWatcherUpdateProperties IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherUpdateProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherUpdateProperties.cs index 5a1109df1050..c17e6bb12a71 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherUpdateProperties.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherUpdateProperties.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models /// The updatable properties of the Watcher. public partial class DatabaseWatcherUpdateProperties { - /// - /// 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 DatabaseWatcherUpdateProperties() @@ -54,16 +25,17 @@ public DatabaseWatcherUpdateProperties() /// Initializes a new instance of . /// The data store for collected monitoring data. /// The resource ID of a user-assigned managed identity that will be assigned to a new alert rule. - /// Keeps track of any properties unknown to the library. - internal DatabaseWatcherUpdateProperties(DatabaseWatcherDatastore datastore, ResourceIdentifier defaultAlertRuleIdentityResourceId, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal DatabaseWatcherUpdateProperties(DatabaseWatcherDatastore datastore, ResourceIdentifier defaultAlertRuleIdentityResourceId, IDictionary additionalBinaryDataProperties) { Datastore = datastore; DefaultAlertRuleIdentityResourceId = defaultAlertRuleIdentityResourceId; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The data store for collected monitoring data. public DatabaseWatcherDatastore Datastore { get; set; } + /// The resource ID of a user-assigned managed identity that will be assigned to a new alert rule. public ResourceIdentifier DefaultAlertRuleIdentityResourceId { get; set; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationListResult.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationListResult.Serialization.cs index b239b328b079..d6fab37cfcf7 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationListResult.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationListResult.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - internal partial class HealthValidationListResult : IUtf8JsonSerializable, IJsonModel + /// The response of a HealthValidation list operation. + internal partial class HealthValidationListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal HealthValidationListResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,15 +35,14 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe /// 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(HealthValidationListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (DatabaseWatcherHealthValidationData item in Value) { writer.WriteObjectValue(item, options); } @@ -46,15 +52,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink.AbsoluteUri); } - 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); } @@ -63,64 +69,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - HealthValidationListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + HealthValidationListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual HealthValidationListResult 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(HealthValidationListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeHealthValidationListResult(document.RootElement, options); } - internal static HealthValidationListResult DeserializeHealthValidationListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HealthValidationListResult DeserializeHealthValidationListResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; Uri nextLink = 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("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DatabaseWatcherHealthValidationData.DeserializeDatabaseWatcherHealthValidationData(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nextLink = new Uri(property.Value.GetString()); + nextLink = 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 HealthValidationListResult(value, nextLink, serializedAdditionalRawData); + return new HealthValidationListResult(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": @@ -130,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriter } } - HealthValidationListResult 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. + HealthValidationListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual HealthValidationListResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeHealthValidationListResult(document.RootElement, options); } default: @@ -146,6 +163,15 @@ HealthValidationListResult IPersistableModel.Create( } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static HealthValidationListResult FromResponse(Response result) + { + using Response response = result; + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeHealthValidationListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationListResult.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationListResult.cs index e5a86a08b5b6..f94929608b30 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationListResult.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationListResult.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { /// The response of a HealthValidation list operation. internal partial class HealthValidationListResult { - /// - /// 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 HealthValidation items on this page. - /// is null. internal HealthValidationListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The HealthValidation items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal HealthValidationListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal HealthValidationListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal HealthValidationListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The HealthValidation items on this page. - public IReadOnlyList Value { get; } + public IList Value { get; } + /// The link to the next page of items. public Uri NextLink { get; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/KustoOfferingType.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/KustoOfferingType.cs index 5650f0cb4d19..87c4f9641d02 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/KustoOfferingType.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/KustoOfferingType.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { @@ -14,41 +15,62 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models public readonly partial struct KustoOfferingType : IEquatable { private readonly string _value; + /// The Azure Data Explorer cluster Kusto offering. + private const string AdxValue = "adx"; + /// The free Azure Data Explorer cluster Kusto offering. + private const string FreeValue = "free"; + /// The Fabric Real-Time Analytics Kusto offering. + private const string FabricValue = "fabric"; /// Initializes a new instance of . + /// The value. /// is null. public KustoOfferingType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string AdxValue = "adx"; - private const string FreeValue = "free"; - private const string FabricValue = "fabric"; + _value = value; + } /// The Azure Data Explorer cluster Kusto offering. public static KustoOfferingType Adx { get; } = new KustoOfferingType(AdxValue); + /// The free Azure Data Explorer cluster Kusto offering. public static KustoOfferingType Free { get; } = new KustoOfferingType(FreeValue); + /// The Fabric Real-Time Analytics Kusto offering. public static KustoOfferingType Fabric { get; } = new KustoOfferingType(FabricValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(KustoOfferingType left, KustoOfferingType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(KustoOfferingType left, KustoOfferingType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator KustoOfferingType(string value) => new KustoOfferingType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator KustoOfferingType?(string value) => value == null ? null : new KustoOfferingType(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is KustoOfferingType other && Equals(other); - /// + + /// public bool Equals(KustoOfferingType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceListResult.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceListResult.Serialization.cs index 1fa6251fe66f..7bea97a1e8f7 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceListResult.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceListResult.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - internal partial class SharedPrivateLinkResourceListResult : IUtf8JsonSerializable, IJsonModel + /// The response of a SharedPrivateLinkResource list operation. + internal partial class SharedPrivateLinkResourceListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal SharedPrivateLinkResourceListResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,15 +35,14 @@ void IJsonModel.Write(Utf8JsonWriter writer /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SharedPrivateLinkResourceListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (DatabaseWatcherSharedPrivateLinkResourceData item in Value) { writer.WriteObjectValue(item, options); } @@ -46,15 +52,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink.AbsoluteUri); } - 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); } @@ -63,64 +69,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - SharedPrivateLinkResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SharedPrivateLinkResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SharedPrivateLinkResourceListResult 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(SharedPrivateLinkResourceListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSharedPrivateLinkResourceListResult(document.RootElement, options); } - internal static SharedPrivateLinkResourceListResult DeserializeSharedPrivateLinkResourceListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SharedPrivateLinkResourceListResult DeserializeSharedPrivateLinkResourceListResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; Uri nextLink = 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("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DatabaseWatcherSharedPrivateLinkResourceData.DeserializeDatabaseWatcherSharedPrivateLinkResourceData(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nextLink = new Uri(property.Value.GetString()); + nextLink = 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 SharedPrivateLinkResourceListResult(value, nextLink, serializedAdditionalRawData); + return new SharedPrivateLinkResourceListResult(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": @@ -130,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelRea } } - SharedPrivateLinkResourceListResult 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. + SharedPrivateLinkResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SharedPrivateLinkResourceListResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSharedPrivateLinkResourceListResult(document.RootElement, options); } default: @@ -146,6 +163,15 @@ SharedPrivateLinkResourceListResult IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static SharedPrivateLinkResourceListResult FromResponse(Response result) + { + using Response response = result; + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeSharedPrivateLinkResourceListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceListResult.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceListResult.cs index ca549a0ef99f..aee57c93cd35 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceListResult.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceListResult.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { /// The response of a SharedPrivateLinkResource list operation. internal partial class SharedPrivateLinkResourceListResult { - /// - /// 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 SharedPrivateLinkResource items on this page. - /// is null. internal SharedPrivateLinkResourceListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The SharedPrivateLinkResource items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal SharedPrivateLinkResourceListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal SharedPrivateLinkResourceListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal SharedPrivateLinkResourceListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The SharedPrivateLinkResource items on this page. - public IReadOnlyList Value { get; } + public IList Value { get; } + /// The link to the next page of items. public Uri NextLink { get; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBElasticPoolTargetProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBElasticPoolTargetProperties.Serialization.cs index 97b4766d8545..23da762a40fc 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBElasticPoolTargetProperties.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBElasticPoolTargetProperties.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - public partial class SqlDBElasticPoolTargetProperties : IUtf8JsonSerializable, IJsonModel + /// The properties specific to an elastic pool in Azure SQL Database. + public partial class SqlDBElasticPoolTargetProperties : DatabaseWatcherTargetProperties, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal SqlDBElasticPoolTargetProperties() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +35,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, M /// 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(SqlDBElasticPoolTargetProperties)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); writer.WritePropertyName("sqlEpResourceId"u8); writer.WriteStringValue(SqlEpResourceId); @@ -46,112 +52,118 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - SqlDBElasticPoolTargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SqlDBElasticPoolTargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SqlDBElasticPoolTargetProperties)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DatabaseWatcherTargetProperties 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(SqlDBElasticPoolTargetProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSqlDBElasticPoolTargetProperties(document.RootElement, options); } - internal static SqlDBElasticPoolTargetProperties DeserializeSqlDBElasticPoolTargetProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SqlDBElasticPoolTargetProperties DeserializeSqlDBElasticPoolTargetProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - ResourceIdentifier sqlEpResourceId = default; - ResourceIdentifier anchorDatabaseResourceId = default; - bool? readIntent = default; - string targetType = default; + string targetType = "SqlEp"; TargetAuthenticationType targetAuthenticationType = default; TargetAuthenticationVaultSecret targetVault = default; string connectionServerName = default; DatabaseWatcherResourceProvisioningState? provisioningState = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResourceIdentifier sqlEpResourceId = default; + ResourceIdentifier anchorDatabaseResourceId = default; + bool? readIntent = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("sqlEpResourceId"u8)) + if (prop.NameEquals("targetType"u8)) { - sqlEpResourceId = new ResourceIdentifier(property.Value.GetString()); + targetType = prop.Value.GetString(); continue; } - if (property.NameEquals("anchorDatabaseResourceId"u8)) + if (prop.NameEquals("targetAuthenticationType"u8)) { - anchorDatabaseResourceId = new ResourceIdentifier(property.Value.GetString()); + targetAuthenticationType = new TargetAuthenticationType(prop.Value.GetString()); continue; } - if (property.NameEquals("readIntent"u8)) + if (prop.NameEquals("targetVault"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - readIntent = property.Value.GetBoolean(); - continue; - } - if (property.NameEquals("targetType"u8)) - { - targetType = property.Value.GetString(); + targetVault = TargetAuthenticationVaultSecret.DeserializeTargetAuthenticationVaultSecret(prop.Value, options); continue; } - if (property.NameEquals("targetAuthenticationType"u8)) + if (prop.NameEquals("connectionServerName"u8)) { - targetAuthenticationType = new TargetAuthenticationType(property.Value.GetString()); + connectionServerName = prop.Value.GetString(); continue; } - if (property.NameEquals("targetVault"u8)) + if (prop.NameEquals("provisioningState"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - targetVault = TargetAuthenticationVaultSecret.DeserializeTargetAuthenticationVaultSecret(property.Value, options); + provisioningState = new DatabaseWatcherResourceProvisioningState(prop.Value.GetString()); continue; } - if (property.NameEquals("connectionServerName"u8)) + if (prop.NameEquals("sqlEpResourceId"u8)) { - connectionServerName = property.Value.GetString(); + sqlEpResourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("provisioningState"u8)) + if (prop.NameEquals("anchorDatabaseResourceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + anchorDatabaseResourceId = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("readIntent"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - provisioningState = new DatabaseWatcherResourceProvisioningState(property.Value.GetString()); + readIntent = prop.Value.GetBoolean(); 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 SqlDBElasticPoolTargetProperties( targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, - serializedAdditionalRawData, + additionalBinaryDataProperties, sqlEpResourceId, anchorDatabaseResourceId, readIntent); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -161,15 +173,20 @@ BinaryData IPersistableModel.Write(ModelReader } } - SqlDBElasticPoolTargetProperties 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. + SqlDBElasticPoolTargetProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SqlDBElasticPoolTargetProperties)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DatabaseWatcherTargetProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSqlDBElasticPoolTargetProperties(document.RootElement, options); } default: @@ -177,6 +194,7 @@ SqlDBElasticPoolTargetProperties IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBElasticPoolTargetProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBElasticPoolTargetProperties.cs index d1c918965a3a..5318637f460b 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBElasticPoolTargetProperties.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBElasticPoolTargetProperties.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { @@ -20,7 +21,7 @@ public partial class SqlDBElasticPoolTargetProperties : DatabaseWatcherTargetPro /// The Azure resource ID of an Azure SQL DB elastic pool target. /// The Azure resource ID of the anchor database used to connect to an elastic pool. /// , or is null. - public SqlDBElasticPoolTargetProperties(TargetAuthenticationType targetAuthenticationType, string connectionServerName, ResourceIdentifier sqlEpResourceId, ResourceIdentifier anchorDatabaseResourceId) : base(targetAuthenticationType, connectionServerName) + public SqlDBElasticPoolTargetProperties(TargetAuthenticationType targetAuthenticationType, string connectionServerName, ResourceIdentifier sqlEpResourceId, ResourceIdentifier anchorDatabaseResourceId) : base("SqlEp", targetAuthenticationType, connectionServerName) { Argument.AssertNotNull(connectionServerName, nameof(connectionServerName)); Argument.AssertNotNull(sqlEpResourceId, nameof(sqlEpResourceId)); @@ -28,7 +29,6 @@ public SqlDBElasticPoolTargetProperties(TargetAuthenticationType targetAuthentic SqlEpResourceId = sqlEpResourceId; AnchorDatabaseResourceId = anchorDatabaseResourceId; - TargetType = "SqlEp"; } /// Initializes a new instance of . @@ -37,27 +37,23 @@ public SqlDBElasticPoolTargetProperties(TargetAuthenticationType targetAuthentic /// To use SQL authentication when connecting to targets, specify the vault where the login name and password secrets are stored. /// The FQDN host name of the server to use in the connection string when connecting to a target. For example, for an Azure SQL logical server in the Azure commercial cloud, the value might be 'sql-logical-server-22092780.database.windows.net'; for an Azure SQL managed instance in the Azure commercial cloud, the value might be 'sql-mi-39441134.767d5869f605.database.windows.net'. Port number and instance name must be specified separately. /// The provisioning state of the resource. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// The Azure resource ID of an Azure SQL DB elastic pool target. /// The Azure resource ID of the anchor database used to connect to an elastic pool. /// Set to true to monitor a high availability replica of specified target, if any. - internal SqlDBElasticPoolTargetProperties(string targetType, TargetAuthenticationType targetAuthenticationType, TargetAuthenticationVaultSecret targetVault, string connectionServerName, DatabaseWatcherResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData, ResourceIdentifier sqlEpResourceId, ResourceIdentifier anchorDatabaseResourceId, bool? readIntent) : base(targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, serializedAdditionalRawData) + internal SqlDBElasticPoolTargetProperties(string targetType, TargetAuthenticationType targetAuthenticationType, TargetAuthenticationVaultSecret targetVault, string connectionServerName, DatabaseWatcherResourceProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties, ResourceIdentifier sqlEpResourceId, ResourceIdentifier anchorDatabaseResourceId, bool? readIntent) : base(targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, additionalBinaryDataProperties) { SqlEpResourceId = sqlEpResourceId; AnchorDatabaseResourceId = anchorDatabaseResourceId; ReadIntent = readIntent; - TargetType = targetType ?? "SqlEp"; - } - - /// Initializes a new instance of for deserialization. - internal SqlDBElasticPoolTargetProperties() - { } /// The Azure resource ID of an Azure SQL DB elastic pool target. public ResourceIdentifier SqlEpResourceId { get; set; } + /// The Azure resource ID of the anchor database used to connect to an elastic pool. public ResourceIdentifier AnchorDatabaseResourceId { get; set; } + /// Set to true to monitor a high availability replica of specified target, if any. public bool? ReadIntent { get; set; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBSingleDatabaseTargetProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBSingleDatabaseTargetProperties.Serialization.cs index 65ee0c447fbe..652e2af1b9f8 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBSingleDatabaseTargetProperties.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBSingleDatabaseTargetProperties.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - public partial class SqlDBSingleDatabaseTargetProperties : IUtf8JsonSerializable, IJsonModel + /// The properties specific to a database in Azure SQL Database. + public partial class SqlDBSingleDatabaseTargetProperties : DatabaseWatcherTargetProperties, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal SqlDBSingleDatabaseTargetProperties() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +35,11 @@ void IJsonModel.Write(Utf8JsonWriter writer /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(SqlDBSingleDatabaseTargetProperties)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); writer.WritePropertyName("sqlDbResourceId"u8); writer.WriteStringValue(SqlDbResourceId); @@ -44,105 +50,111 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - SqlDBSingleDatabaseTargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SqlDBSingleDatabaseTargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SqlDBSingleDatabaseTargetProperties)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DatabaseWatcherTargetProperties 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(SqlDBSingleDatabaseTargetProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSqlDBSingleDatabaseTargetProperties(document.RootElement, options); } - internal static SqlDBSingleDatabaseTargetProperties DeserializeSqlDBSingleDatabaseTargetProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SqlDBSingleDatabaseTargetProperties DeserializeSqlDBSingleDatabaseTargetProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - ResourceIdentifier sqlDbResourceId = default; - bool? readIntent = default; - string targetType = default; + string targetType = "SqlDb"; TargetAuthenticationType targetAuthenticationType = default; TargetAuthenticationVaultSecret targetVault = default; string connectionServerName = default; DatabaseWatcherResourceProvisioningState? provisioningState = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResourceIdentifier sqlDbResourceId = default; + bool? readIntent = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("sqlDbResourceId"u8)) + if (prop.NameEquals("targetType"u8)) { - sqlDbResourceId = new ResourceIdentifier(property.Value.GetString()); + targetType = prop.Value.GetString(); continue; } - if (property.NameEquals("readIntent"u8)) + if (prop.NameEquals("targetAuthenticationType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - readIntent = property.Value.GetBoolean(); + targetAuthenticationType = new TargetAuthenticationType(prop.Value.GetString()); continue; } - if (property.NameEquals("targetType"u8)) + if (prop.NameEquals("targetVault"u8)) { - targetType = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetVault = TargetAuthenticationVaultSecret.DeserializeTargetAuthenticationVaultSecret(prop.Value, options); continue; } - if (property.NameEquals("targetAuthenticationType"u8)) + if (prop.NameEquals("connectionServerName"u8)) { - targetAuthenticationType = new TargetAuthenticationType(property.Value.GetString()); + connectionServerName = prop.Value.GetString(); continue; } - if (property.NameEquals("targetVault"u8)) + if (prop.NameEquals("provisioningState"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - targetVault = TargetAuthenticationVaultSecret.DeserializeTargetAuthenticationVaultSecret(property.Value, options); + provisioningState = new DatabaseWatcherResourceProvisioningState(prop.Value.GetString()); continue; } - if (property.NameEquals("connectionServerName"u8)) + if (prop.NameEquals("sqlDbResourceId"u8)) { - connectionServerName = property.Value.GetString(); + sqlDbResourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("provisioningState"u8)) + if (prop.NameEquals("readIntent"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - provisioningState = new DatabaseWatcherResourceProvisioningState(property.Value.GetString()); + readIntent = prop.Value.GetBoolean(); 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 SqlDBSingleDatabaseTargetProperties( targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, - serializedAdditionalRawData, + additionalBinaryDataProperties, sqlDbResourceId, readIntent); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -152,15 +164,20 @@ BinaryData IPersistableModel.Write(ModelRea } } - SqlDBSingleDatabaseTargetProperties 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. + SqlDBSingleDatabaseTargetProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SqlDBSingleDatabaseTargetProperties)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DatabaseWatcherTargetProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSqlDBSingleDatabaseTargetProperties(document.RootElement, options); } default: @@ -168,6 +185,7 @@ SqlDBSingleDatabaseTargetProperties IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBSingleDatabaseTargetProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBSingleDatabaseTargetProperties.cs index 1888018e4568..9e958af7afb4 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBSingleDatabaseTargetProperties.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDBSingleDatabaseTargetProperties.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { @@ -19,13 +20,12 @@ public partial class SqlDBSingleDatabaseTargetProperties : DatabaseWatcherTarget /// The FQDN host name of the server to use in the connection string when connecting to a target. For example, for an Azure SQL logical server in the Azure commercial cloud, the value might be 'sql-logical-server-22092780.database.windows.net'; for an Azure SQL managed instance in the Azure commercial cloud, the value might be 'sql-mi-39441134.767d5869f605.database.windows.net'. Port number and instance name must be specified separately. /// The Azure resource ID of an Azure SQL DB database target. /// or is null. - public SqlDBSingleDatabaseTargetProperties(TargetAuthenticationType targetAuthenticationType, string connectionServerName, ResourceIdentifier sqlDbResourceId) : base(targetAuthenticationType, connectionServerName) + public SqlDBSingleDatabaseTargetProperties(TargetAuthenticationType targetAuthenticationType, string connectionServerName, ResourceIdentifier sqlDbResourceId) : base("SqlDb", targetAuthenticationType, connectionServerName) { Argument.AssertNotNull(connectionServerName, nameof(connectionServerName)); Argument.AssertNotNull(sqlDbResourceId, nameof(sqlDbResourceId)); SqlDbResourceId = sqlDbResourceId; - TargetType = "SqlDb"; } /// Initializes a new instance of . @@ -34,23 +34,18 @@ public SqlDBSingleDatabaseTargetProperties(TargetAuthenticationType targetAuthen /// To use SQL authentication when connecting to targets, specify the vault where the login name and password secrets are stored. /// The FQDN host name of the server to use in the connection string when connecting to a target. For example, for an Azure SQL logical server in the Azure commercial cloud, the value might be 'sql-logical-server-22092780.database.windows.net'; for an Azure SQL managed instance in the Azure commercial cloud, the value might be 'sql-mi-39441134.767d5869f605.database.windows.net'. Port number and instance name must be specified separately. /// The provisioning state of the resource. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// The Azure resource ID of an Azure SQL DB database target. /// Set to true to monitor a high availability replica of specified target, if any. - internal SqlDBSingleDatabaseTargetProperties(string targetType, TargetAuthenticationType targetAuthenticationType, TargetAuthenticationVaultSecret targetVault, string connectionServerName, DatabaseWatcherResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData, ResourceIdentifier sqlDbResourceId, bool? readIntent) : base(targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, serializedAdditionalRawData) + internal SqlDBSingleDatabaseTargetProperties(string targetType, TargetAuthenticationType targetAuthenticationType, TargetAuthenticationVaultSecret targetVault, string connectionServerName, DatabaseWatcherResourceProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties, ResourceIdentifier sqlDbResourceId, bool? readIntent) : base(targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, additionalBinaryDataProperties) { SqlDbResourceId = sqlDbResourceId; ReadIntent = readIntent; - TargetType = targetType ?? "SqlDb"; - } - - /// Initializes a new instance of for deserialization. - internal SqlDBSingleDatabaseTargetProperties() - { } /// The Azure resource ID of an Azure SQL DB database target. public ResourceIdentifier SqlDbResourceId { get; set; } + /// Set to true to monitor a high availability replica of specified target, if any. public bool? ReadIntent { get; set; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlMITargetProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlMITargetProperties.Serialization.cs index b39657c004bb..c2dc607a6324 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlMITargetProperties.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlMITargetProperties.Serialization.cs @@ -10,13 +10,20 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - public partial class SqlMITargetProperties : IUtf8JsonSerializable, IJsonModel + /// The properties specific to Azure SQL Managed Instance targets. + public partial class SqlMITargetProperties : DatabaseWatcherTargetProperties, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal SqlMITargetProperties() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +35,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// 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(SqlMITargetProperties)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); writer.WritePropertyName("sqlMiResourceId"u8); writer.WriteStringValue(SqlMiResourceId); @@ -49,116 +55,122 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri } } - SqlMITargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + SqlMITargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SqlMITargetProperties)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DatabaseWatcherTargetProperties 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(SqlMITargetProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeSqlMITargetProperties(document.RootElement, options); } - internal static SqlMITargetProperties DeserializeSqlMITargetProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SqlMITargetProperties DeserializeSqlMITargetProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - ResourceIdentifier sqlMiResourceId = default; - int? connectionTcpPort = default; - bool? readIntent = default; - string targetType = default; + string targetType = "SqlMi"; TargetAuthenticationType targetAuthenticationType = default; TargetAuthenticationVaultSecret targetVault = default; string connectionServerName = default; DatabaseWatcherResourceProvisioningState? provisioningState = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResourceIdentifier sqlMiResourceId = default; + int? connectionTcpPort = default; + bool? readIntent = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("sqlMiResourceId"u8)) + if (prop.NameEquals("targetType"u8)) { - sqlMiResourceId = new ResourceIdentifier(property.Value.GetString()); + targetType = prop.Value.GetString(); continue; } - if (property.NameEquals("connectionTcpPort"u8)) + if (prop.NameEquals("targetAuthenticationType"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - connectionTcpPort = property.Value.GetInt32(); + targetAuthenticationType = new TargetAuthenticationType(prop.Value.GetString()); continue; } - if (property.NameEquals("readIntent"u8)) + if (prop.NameEquals("targetVault"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - readIntent = property.Value.GetBoolean(); + targetVault = TargetAuthenticationVaultSecret.DeserializeTargetAuthenticationVaultSecret(prop.Value, options); continue; } - if (property.NameEquals("targetType"u8)) + if (prop.NameEquals("connectionServerName"u8)) { - targetType = property.Value.GetString(); + connectionServerName = prop.Value.GetString(); continue; } - if (property.NameEquals("targetAuthenticationType"u8)) + if (prop.NameEquals("provisioningState"u8)) { - targetAuthenticationType = new TargetAuthenticationType(property.Value.GetString()); - continue; - } - if (property.NameEquals("targetVault"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - targetVault = TargetAuthenticationVaultSecret.DeserializeTargetAuthenticationVaultSecret(property.Value, options); + provisioningState = new DatabaseWatcherResourceProvisioningState(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("sqlMiResourceId"u8)) + { + sqlMiResourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("connectionServerName"u8)) + if (prop.NameEquals("connectionTcpPort"u8)) { - connectionServerName = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + connectionTcpPort = prop.Value.GetInt32(); continue; } - if (property.NameEquals("provisioningState"u8)) + if (prop.NameEquals("readIntent"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - provisioningState = new DatabaseWatcherResourceProvisioningState(property.Value.GetString()); + readIntent = prop.Value.GetBoolean(); 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 SqlMITargetProperties( targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, - serializedAdditionalRawData, + additionalBinaryDataProperties, sqlMiResourceId, connectionTcpPort, readIntent); } - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -168,15 +180,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - SqlMITargetProperties 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. + SqlMITargetProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SqlMITargetProperties)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DatabaseWatcherTargetProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeSqlMITargetProperties(document.RootElement, options); } default: @@ -184,6 +201,7 @@ SqlMITargetProperties IPersistableModel.Create(BinaryData } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlMITargetProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlMITargetProperties.cs index d09e3c8a7235..c2cc4ba25b42 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlMITargetProperties.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlMITargetProperties.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { @@ -19,13 +20,12 @@ public partial class SqlMITargetProperties : DatabaseWatcherTargetProperties /// The FQDN host name of the server to use in the connection string when connecting to a target. For example, for an Azure SQL logical server in the Azure commercial cloud, the value might be 'sql-logical-server-22092780.database.windows.net'; for an Azure SQL managed instance in the Azure commercial cloud, the value might be 'sql-mi-39441134.767d5869f605.database.windows.net'. Port number and instance name must be specified separately. /// The Azure resource ID of an Azure SQL Managed Instance target. /// or is null. - public SqlMITargetProperties(TargetAuthenticationType targetAuthenticationType, string connectionServerName, ResourceIdentifier sqlMiResourceId) : base(targetAuthenticationType, connectionServerName) + public SqlMITargetProperties(TargetAuthenticationType targetAuthenticationType, string connectionServerName, ResourceIdentifier sqlMiResourceId) : base("SqlMi", targetAuthenticationType, connectionServerName) { Argument.AssertNotNull(connectionServerName, nameof(connectionServerName)); Argument.AssertNotNull(sqlMiResourceId, nameof(sqlMiResourceId)); SqlMiResourceId = sqlMiResourceId; - TargetType = "SqlMi"; } /// Initializes a new instance of . @@ -34,27 +34,23 @@ public SqlMITargetProperties(TargetAuthenticationType targetAuthenticationType, /// To use SQL authentication when connecting to targets, specify the vault where the login name and password secrets are stored. /// The FQDN host name of the server to use in the connection string when connecting to a target. For example, for an Azure SQL logical server in the Azure commercial cloud, the value might be 'sql-logical-server-22092780.database.windows.net'; for an Azure SQL managed instance in the Azure commercial cloud, the value might be 'sql-mi-39441134.767d5869f605.database.windows.net'. Port number and instance name must be specified separately. /// The provisioning state of the resource. - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// The Azure resource ID of an Azure SQL Managed Instance target. /// The TCP port number to optionally use in the connection string when connecting to an Azure SQL Managed Instance target. /// Set to true to monitor a high availability replica of specified target, if any. - internal SqlMITargetProperties(string targetType, TargetAuthenticationType targetAuthenticationType, TargetAuthenticationVaultSecret targetVault, string connectionServerName, DatabaseWatcherResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData, ResourceIdentifier sqlMiResourceId, int? connectionTcpPort, bool? readIntent) : base(targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, serializedAdditionalRawData) + internal SqlMITargetProperties(string targetType, TargetAuthenticationType targetAuthenticationType, TargetAuthenticationVaultSecret targetVault, string connectionServerName, DatabaseWatcherResourceProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties, ResourceIdentifier sqlMiResourceId, int? connectionTcpPort, bool? readIntent) : base(targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, additionalBinaryDataProperties) { SqlMiResourceId = sqlMiResourceId; ConnectionTcpPort = connectionTcpPort; ReadIntent = readIntent; - TargetType = targetType ?? "SqlMi"; - } - - /// Initializes a new instance of for deserialization. - internal SqlMITargetProperties() - { } /// The Azure resource ID of an Azure SQL Managed Instance target. public ResourceIdentifier SqlMiResourceId { get; set; } + /// The TCP port number to optionally use in the connection string when connecting to an Azure SQL Managed Instance target. public int? ConnectionTcpPort { get; set; } + /// Set to true to monitor a high availability replica of specified target, if any. public bool? ReadIntent { get; set; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetAuthenticationType.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetAuthenticationType.cs index c75adb8f1d8a..f33fcd0455d1 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetAuthenticationType.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetAuthenticationType.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { @@ -14,38 +15,57 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models public readonly partial struct TargetAuthenticationType : IEquatable { private readonly string _value; + /// The Azure Active Directory authentication. + private const string AadValue = "Aad"; + /// The SQL password authentication. + private const string SqlValue = "Sql"; /// Initializes a new instance of . + /// The value. /// is null. public TargetAuthenticationType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string AadValue = "Aad"; - private const string SqlValue = "Sql"; + _value = value; + } /// The Azure Active Directory authentication. public static TargetAuthenticationType Aad { get; } = new TargetAuthenticationType(AadValue); + /// The SQL password authentication. public static TargetAuthenticationType Sql { get; } = new TargetAuthenticationType(SqlValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(TargetAuthenticationType left, TargetAuthenticationType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(TargetAuthenticationType left, TargetAuthenticationType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator TargetAuthenticationType(string value) => new TargetAuthenticationType(value); - /// + /// Converts a string to a . + /// The value. + public static implicit operator TargetAuthenticationType?(string value) => value == null ? null : new TargetAuthenticationType(value); + + /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is TargetAuthenticationType other && Equals(other); - /// + + /// public bool Equals(TargetAuthenticationType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetAuthenticationVaultSecret.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetAuthenticationVaultSecret.Serialization.cs index c3c0d331702c..bf28bf24a98d 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetAuthenticationVaultSecret.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetAuthenticationVaultSecret.Serialization.cs @@ -10,13 +10,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - public partial class TargetAuthenticationVaultSecret : IUtf8JsonSerializable, IJsonModel + /// The vault specific details required if using SQL authentication to connect to a target. + public partial class TargetAuthenticationVaultSecret : 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, Mo /// 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(TargetAuthenticationVaultSecret)} does not support writing '{format}' format."); } - if (Optional.IsDefined(AkvResourceId)) { writer.WritePropertyName("akvResourceId"u8); @@ -49,15 +50,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("akvTargetPassword"u8); writer.WriteStringValue(AkvTargetPassword); } - 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); } @@ -66,22 +67,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TargetAuthenticationVaultSecret IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TargetAuthenticationVaultSecret IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TargetAuthenticationVaultSecret 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(TargetAuthenticationVaultSecret)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTargetAuthenticationVaultSecret(document.RootElement, options); } - internal static TargetAuthenticationVaultSecret DeserializeTargetAuthenticationVaultSecret(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TargetAuthenticationVaultSecret DeserializeTargetAuthenticationVaultSecret(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,42 +95,43 @@ internal static TargetAuthenticationVaultSecret DeserializeTargetAuthenticationV ResourceIdentifier akvResourceId = default; string akvTargetUser = default; string akvTargetPassword = 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("akvResourceId"u8)) + if (prop.NameEquals("akvResourceId"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - akvResourceId = new ResourceIdentifier(property.Value.GetString()); + akvResourceId = new ResourceIdentifier(prop.Value.GetString()); continue; } - if (property.NameEquals("akvTargetUser"u8)) + if (prop.NameEquals("akvTargetUser"u8)) { - akvTargetUser = property.Value.GetString(); + akvTargetUser = prop.Value.GetString(); continue; } - if (property.NameEquals("akvTargetPassword"u8)) + if (prop.NameEquals("akvTargetPassword"u8)) { - akvTargetPassword = property.Value.GetString(); + akvTargetPassword = 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 TargetAuthenticationVaultSecret(akvResourceId, akvTargetUser, akvTargetPassword, serializedAdditionalRawData); + return new TargetAuthenticationVaultSecret(akvResourceId, akvTargetUser, akvTargetPassword, 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": @@ -134,15 +141,20 @@ BinaryData IPersistableModel.Write(ModelReaderW } } - TargetAuthenticationVaultSecret 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. + TargetAuthenticationVaultSecret IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TargetAuthenticationVaultSecret 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTargetAuthenticationVaultSecret(document.RootElement, options); } default: @@ -150,6 +162,7 @@ TargetAuthenticationVaultSecret IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetAuthenticationVaultSecret.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetAuthenticationVaultSecret.cs index e25c799d6315..567b852a519d 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetAuthenticationVaultSecret.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetAuthenticationVaultSecret.cs @@ -14,37 +14,8 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models /// The vault specific details required if using SQL authentication to connect to a target. public partial class TargetAuthenticationVaultSecret { - /// - /// 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 TargetAuthenticationVaultSecret() @@ -55,19 +26,21 @@ public TargetAuthenticationVaultSecret() /// The Azure resource ID of the Key Vault instance storing database authentication secrets. /// The path to the Key Vault secret storing the login name (aka user name, aka account name) for authentication to a target. /// The path to the Key Vault secret storing the password for authentication to a target. - /// Keeps track of any properties unknown to the library. - internal TargetAuthenticationVaultSecret(ResourceIdentifier akvResourceId, string akvTargetUser, string akvTargetPassword, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TargetAuthenticationVaultSecret(ResourceIdentifier akvResourceId, string akvTargetUser, string akvTargetPassword, IDictionary additionalBinaryDataProperties) { AkvResourceId = akvResourceId; AkvTargetUser = akvTargetUser; AkvTargetPassword = akvTargetPassword; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The Azure resource ID of the Key Vault instance storing database authentication secrets. public ResourceIdentifier AkvResourceId { get; set; } + /// The path to the Key Vault secret storing the login name (aka user name, aka account name) for authentication to a target. public string AkvTargetUser { get; set; } + /// The path to the Key Vault secret storing the password for authentication to a target. public string AkvTargetPassword { get; set; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetListResult.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetListResult.Serialization.cs index 8ae79537a6a2..9b11aa48b2b2 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetListResult.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetListResult.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - internal partial class TargetListResult : IUtf8JsonSerializable, IJsonModel + /// The response of a Target list operation. + internal partial class TargetListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal TargetListResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,15 +35,14 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter /// 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(TargetListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (DatabaseWatcherTargetData item in Value) { writer.WriteObjectValue(item, options); } @@ -46,15 +52,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink.AbsoluteUri); } - 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); } @@ -63,64 +69,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - TargetListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + TargetListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TargetListResult 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(TargetListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeTargetListResult(document.RootElement, options); } - internal static TargetListResult DeserializeTargetListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TargetListResult DeserializeTargetListResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; Uri nextLink = 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("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DatabaseWatcherTargetData.DeserializeDatabaseWatcherTargetData(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nextLink = new Uri(property.Value.GetString()); + nextLink = 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 TargetListResult(value, nextLink, serializedAdditionalRawData); + return new TargetListResult(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": @@ -130,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions op } } - TargetListResult 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. + TargetListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TargetListResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeTargetListResult(document.RootElement, options); } default: @@ -146,6 +163,15 @@ TargetListResult IPersistableModel.Create(BinaryData data, Mod } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static TargetListResult FromResponse(Response result) + { + using Response response = result; + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeTargetListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetListResult.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetListResult.cs index 5c1e5282781a..2bc528e68969 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetListResult.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetListResult.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { /// The response of a Target list operation. internal partial class TargetListResult { - /// - /// 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 Target items on this page. - /// is null. internal TargetListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The Target items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal TargetListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal TargetListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal TargetListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The Target items on this page. - public IReadOnlyList Value { get; } + public IList Value { get; } + /// The link to the next page of items. public Uri NextLink { get; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/UnknownDatabaseWatcherTargetProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/UnknownDatabaseWatcherTargetProperties.Serialization.cs index dec9ae27f9ee..92261e6e2610 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/UnknownDatabaseWatcherTargetProperties.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/UnknownDatabaseWatcherTargetProperties.Serialization.cs @@ -9,14 +9,19 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - internal partial class UnknownDatabaseWatcherTargetProperties : IUtf8JsonSerializable, IJsonModel + internal partial class UnknownDatabaseWatcherTargetProperties : DatabaseWatcherTargetProperties, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal UnknownDatabaseWatcherTargetProperties() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,96 +33,101 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo /// 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(DatabaseWatcherTargetProperties)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - DatabaseWatcherTargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + DatabaseWatcherTargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override DatabaseWatcherTargetProperties 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(DatabaseWatcherTargetProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDatabaseWatcherTargetProperties(document.RootElement, options); } - internal static UnknownDatabaseWatcherTargetProperties DeserializeUnknownDatabaseWatcherTargetProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownDatabaseWatcherTargetProperties DeserializeUnknownDatabaseWatcherTargetProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - string targetType = "Unknown"; + string targetType = "unknown"; TargetAuthenticationType targetAuthenticationType = default; TargetAuthenticationVaultSecret targetVault = default; string connectionServerName = default; DatabaseWatcherResourceProvisioningState? provisioningState = 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("targetType"u8)) + if (prop.NameEquals("targetType"u8)) { - targetType = property.Value.GetString(); + targetType = prop.Value.GetString(); continue; } - if (property.NameEquals("targetAuthenticationType"u8)) + if (prop.NameEquals("targetAuthenticationType"u8)) { - targetAuthenticationType = new TargetAuthenticationType(property.Value.GetString()); + targetAuthenticationType = new TargetAuthenticationType(prop.Value.GetString()); continue; } - if (property.NameEquals("targetVault"u8)) + if (prop.NameEquals("targetVault"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - targetVault = TargetAuthenticationVaultSecret.DeserializeTargetAuthenticationVaultSecret(property.Value, options); + targetVault = TargetAuthenticationVaultSecret.DeserializeTargetAuthenticationVaultSecret(prop.Value, options); continue; } - if (property.NameEquals("connectionServerName"u8)) + if (prop.NameEquals("connectionServerName"u8)) { - connectionServerName = property.Value.GetString(); + connectionServerName = prop.Value.GetString(); continue; } - if (property.NameEquals("provisioningState"u8)) + if (prop.NameEquals("provisioningState"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - provisioningState = new DatabaseWatcherResourceProvisioningState(property.Value.GetString()); + provisioningState = new DatabaseWatcherResourceProvisioningState(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 UnknownDatabaseWatcherTargetProperties( targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, - 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 override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -127,15 +137,20 @@ BinaryData IPersistableModel.Write(ModelReaderW } } - DatabaseWatcherTargetProperties 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. + DatabaseWatcherTargetProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override DatabaseWatcherTargetProperties 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeDatabaseWatcherTargetProperties(document.RootElement, options); } default: @@ -143,6 +158,7 @@ DatabaseWatcherTargetProperties IPersistableModel The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/UnknownDatabaseWatcherTargetProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/UnknownDatabaseWatcherTargetProperties.cs index afc4a5f4000e..3f4434c32519 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/UnknownDatabaseWatcherTargetProperties.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/UnknownDatabaseWatcherTargetProperties.cs @@ -10,7 +10,6 @@ namespace Azure.ResourceManager.DatabaseWatcher.Models { - /// Unknown version of DatabaseWatcherTargetProperties. internal partial class UnknownDatabaseWatcherTargetProperties : DatabaseWatcherTargetProperties { /// Initializes a new instance of . @@ -19,14 +18,8 @@ internal partial class UnknownDatabaseWatcherTargetProperties : DatabaseWatcherT /// To use SQL authentication when connecting to targets, specify the vault where the login name and password secrets are stored. /// The FQDN host name of the server to use in the connection string when connecting to a target. For example, for an Azure SQL logical server in the Azure commercial cloud, the value might be 'sql-logical-server-22092780.database.windows.net'; for an Azure SQL managed instance in the Azure commercial cloud, the value might be 'sql-mi-39441134.767d5869f605.database.windows.net'. Port number and instance name must be specified separately. /// The provisioning state of the resource. - /// Keeps track of any properties unknown to the library. - internal UnknownDatabaseWatcherTargetProperties(string targetType, TargetAuthenticationType targetAuthenticationType, TargetAuthenticationVaultSecret targetVault, string connectionServerName, DatabaseWatcherResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) : base(targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, serializedAdditionalRawData) - { - TargetType = targetType ?? "Unknown"; - } - - /// Initializes a new instance of for deserialization. - internal UnknownDatabaseWatcherTargetProperties() + /// Keeps track of any properties unknown to the library. + internal UnknownDatabaseWatcherTargetProperties(string targetType, TargetAuthenticationType targetAuthenticationType, TargetAuthenticationVaultSecret targetVault, string connectionServerName, DatabaseWatcherResourceProvisioningState? provisioningState, IDictionary additionalBinaryDataProperties) : base(targetType ?? "unknown", targetAuthenticationType, targetVault, connectionServerName, provisioningState, additionalBinaryDataProperties) { } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherListResult.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherListResult.Serialization.cs index 141ff9b509b9..f76d1eca1b6e 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherListResult.Serialization.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherListResult.Serialization.cs @@ -9,14 +9,21 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { - internal partial class WatcherListResult : IUtf8JsonSerializable, IJsonModel + /// The response of a Watcher list operation. + internal partial class WatcherListResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal WatcherListResult() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,15 +35,14 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite /// 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(WatcherListResult)} does not support writing '{format}' format."); } - writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (DatabaseWatcherData item in Value) { writer.WriteObjectValue(item, options); } @@ -46,15 +52,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("nextLink"u8); writer.WriteStringValue(NextLink.AbsoluteUri); } - 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); } @@ -63,64 +69,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - WatcherListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + WatcherListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual WatcherListResult 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(WatcherListResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeWatcherListResult(document.RootElement, options); } - internal static WatcherListResult DeserializeWatcherListResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WatcherListResult DeserializeWatcherListResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - IReadOnlyList value = default; + IList value = default; Uri nextLink = 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("value"u8)) + if (prop.NameEquals("value"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(DatabaseWatcherData.DeserializeDatabaseWatcherData(item, options)); } value = array; continue; } - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - nextLink = new Uri(property.Value.GetString()); + nextLink = 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 WatcherListResult(value, nextLink, serializedAdditionalRawData); + return new WatcherListResult(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": @@ -130,15 +142,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions o } } - WatcherListResult 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. + WatcherListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual WatcherListResult 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)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeWatcherListResult(document.RootElement, options); } default: @@ -146,6 +163,15 @@ WatcherListResult IPersistableModel.Create(BinaryData data, M } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static WatcherListResult FromResponse(Response result) + { + using Response response = result; + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeWatcherListResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherListResult.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherListResult.cs index f3d8b4e595b7..ec192941a097 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherListResult.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherListResult.cs @@ -8,72 +8,37 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.ResourceManager.DatabaseWatcher; namespace Azure.ResourceManager.DatabaseWatcher.Models { /// The response of a Watcher list operation. internal partial class WatcherListResult { - /// - /// 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 Watcher items on this page. - /// is null. internal WatcherListResult(IEnumerable value) { - Argument.AssertNotNull(value, nameof(value)); - Value = value.ToList(); } /// Initializes a new instance of . /// The Watcher items on this page. /// The link to the next page of items. - /// Keeps track of any properties unknown to the library. - internal WatcherListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal WatcherListResult(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { Value = value; NextLink = nextLink; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal WatcherListResult() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The Watcher items on this page. - public IReadOnlyList Value { get; } + public IList Value { get; } + /// The link to the next page of items. public Uri NextLink { get; } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/ProviderConstants.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/ProviderConstants.cs index 4bbac7bcb68c..53d9734ec156 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/ProviderConstants.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/ProviderConstants.cs @@ -9,8 +9,9 @@ namespace Azure.ResourceManager.DatabaseWatcher { - 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/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/AlertRuleResourcesRestOperations.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/AlertRuleResourcesRestOperations.cs index cd972b1fc201..b07d503ddb6d 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/AlertRuleResourcesRestOperations.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/AlertRuleResourcesRestOperations.cs @@ -6,146 +6,47 @@ #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.DatabaseWatcher.Models; namespace Azure.ResourceManager.DatabaseWatcher { - internal partial class AlertRuleResourcesRestOperations + internal partial class AlertRuleResources { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of AlertRuleResourcesRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public AlertRuleResourcesRestOperations(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-01-02"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName) - { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/alertRuleResources/", false); - uri.AppendPath(alertRuleResourceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName) + /// Initializes a new instance of AlertRuleResources for mocking. + protected AlertRuleResources() { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/alertRuleResources/", false); - uri.AppendPath(alertRuleResourceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; } - /// Get a AlertRuleResource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The alert rule proxy resource name. - /// 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 watcherName, string alertRuleResourceName, CancellationToken cancellationToken = default) + /// Initializes a new instance of AlertRuleResources. + /// 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 AlertRuleResources(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, watcherName, alertRuleResourceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DatabaseWatcherAlertRuleData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DatabaseWatcherAlertRuleData.DeserializeDatabaseWatcherAlertRuleData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DatabaseWatcherAlertRuleData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Get a AlertRuleResource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The alert rule proxy resource name. - /// 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 watcherName, string alertRuleResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, watcherName, alertRuleResourceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DatabaseWatcherAlertRuleData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DatabaseWatcherAlertRuleData.DeserializeDatabaseWatcherAlertRuleData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DatabaseWatcherAlertRuleData)null, 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 CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName, DatabaseWatcherAlertRuleData data) + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); @@ -153,18 +54,20 @@ internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, uri.AppendPath("/alertRuleResources/", false); uri.AppendPath(alertRuleResourceName, 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 CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName, DatabaseWatcherAlertRuleData data) + internal HttpMessage CreateCreateOrUpdateRequest(Guid subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); @@ -172,109 +75,22 @@ internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string r uri.AppendPath("/alertRuleResources/", false); uri.AppendPath(alertRuleResourceName, 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(data, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Create a AlertRuleResource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The alert rule proxy resource name. - /// Resource create parameters. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName, DatabaseWatcherAlertRuleData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, watcherName, alertRuleResourceName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - { - DatabaseWatcherAlertRuleData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DatabaseWatcherAlertRuleData.DeserializeDatabaseWatcherAlertRuleData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Create a AlertRuleResource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The alert rule proxy resource name. - /// Resource create parameters. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName, DatabaseWatcherAlertRuleData data, CancellationToken cancellationToken = default) + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, watcherName, alertRuleResourceName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - { - DatabaseWatcherAlertRuleData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DatabaseWatcherAlertRuleData.DeserializeDatabaseWatcherAlertRuleData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName) - { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/alertRuleResources/", false); - uri.AppendPath(alertRuleResourceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); @@ -282,241 +98,43 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath("/alertRuleResources/", false); uri.AppendPath(alertRuleResourceName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Delete a AlertRuleResource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The alert rule proxy resource name. - /// 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 watcherName, string alertRuleResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, watcherName, alertRuleResourceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a AlertRuleResource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The alert rule proxy resource name. - /// 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 watcherName, string alertRuleResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, watcherName, alertRuleResourceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByParentRequestUri(string subscriptionId, string resourceGroupName, string watcherName) + internal HttpMessage CreateGetByParentRequest(Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/alertRuleResources", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListByParentRequest(string subscriptionId, string resourceGroupName, string watcherName) - { - 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(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); uri.AppendPath(watcherName, true); uri.AppendPath("/alertRuleResources", 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 AlertRuleResource resources by Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListByParentAsync(string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetByParentRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByParentRequest(subscriptionId, resourceGroupName, watcherName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - AlertRuleResourceListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = AlertRuleResourceListResult.DeserializeAlertRuleResourceListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List AlertRuleResource resources by Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListByParent(string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByParentRequest(subscriptionId, resourceGroupName, watcherName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - AlertRuleResourceListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = AlertRuleResourceListResult.DeserializeAlertRuleResourceListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByParentNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string watcherName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByParentNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string watcherName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + 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 AlertRuleResource resources by Watcher. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListByParentNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByParentNextPageRequest(nextLink, subscriptionId, resourceGroupName, watcherName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - AlertRuleResourceListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = AlertRuleResourceListResult.DeserializeAlertRuleResourceListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List AlertRuleResource resources by Watcher. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListByParentNextPage(string nextLink, string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByParentNextPageRequest(nextLink, subscriptionId, resourceGroupName, watcherName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - AlertRuleResourceListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = AlertRuleResourceListResult.DeserializeAlertRuleResourceListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/HealthValidationsRestOperations.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/HealthValidationsRestOperations.cs index de174dbce59c..e9a234aeb6fd 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/HealthValidationsRestOperations.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/HealthValidationsRestOperations.cs @@ -6,61 +6,47 @@ #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.DatabaseWatcher.Models; namespace Azure.ResourceManager.DatabaseWatcher { - internal partial class HealthValidationsRestOperations + internal partial class HealthValidations { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of HealthValidationsRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public HealthValidationsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of HealthValidations for mocking. + protected HealthValidations() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-01-02"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string watcherName, string healthValidationName) + /// Initializes a new instance of HealthValidations. + /// 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 HealthValidations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/healthValidations/", false); - uri.AppendPath(healthValidationName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string watcherName, string healthValidationName) + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string watcherName, string healthValidationName, 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); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); @@ -68,198 +54,52 @@ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGrou uri.AppendPath("/healthValidations/", false); uri.AppendPath(healthValidationName, 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.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Get a HealthValidation. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The health validation resource name. - /// 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 watcherName, string healthValidationName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetByParentRequest(Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, watcherName, healthValidationName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DatabaseWatcherHealthValidationData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DatabaseWatcherHealthValidationData.DeserializeDatabaseWatcherHealthValidationData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DatabaseWatcherHealthValidationData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - /// Get a HealthValidation. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The health validation resource name. - /// 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 watcherName, string healthValidationName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, watcherName, healthValidationName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DatabaseWatcherHealthValidationData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DatabaseWatcherHealthValidationData.DeserializeDatabaseWatcherHealthValidationData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DatabaseWatcherHealthValidationData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByParentRequestUri(string subscriptionId, string resourceGroupName, string watcherName) - { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/healthValidations", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListByParentRequest(string subscriptionId, string resourceGroupName, string watcherName) - { - 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(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); uri.AppendPath(watcherName, true); uri.AppendPath("/healthValidations", 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 HealthValidation resources by Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListByParentAsync(string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByParentRequest(subscriptionId, resourceGroupName, watcherName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - HealthValidationListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = HealthValidationListResult.DeserializeHealthValidationListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List HealthValidation resources by Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListByParent(string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByParentRequest(subscriptionId, resourceGroupName, watcherName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - HealthValidationListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = HealthValidationListResult.DeserializeHealthValidationListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateStartValidationRequestUri(string subscriptionId, string resourceGroupName, string watcherName, string healthValidationName) + internal HttpMessage CreateNextGetByParentRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string watcherName, 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/healthValidations/", false); - uri.AppendPath(healthValidationName, true); - uri.AppendPath("/startValidation", 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 CreateStartValidationRequest(string subscriptionId, string resourceGroupName, string watcherName, string healthValidationName) + internal HttpMessage CreateStartValidationRequest(Guid subscriptionId, string resourceGroupName, string watcherName, string healthValidationName, 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(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); @@ -268,148 +108,12 @@ internal HttpMessage CreateStartValidationRequest(string subscriptionId, string uri.AppendPath(healthValidationName, true); uri.AppendPath("/startValidation", 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; - } - - /// Starts health validation for a watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The health validation resource name. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task StartValidationAsync(string subscriptionId, string resourceGroupName, string watcherName, string healthValidationName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); - - using var message = CreateStartValidationRequest(subscriptionId, resourceGroupName, watcherName, healthValidationName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - case 200: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Starts health validation for a watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The health validation resource name. - /// The cancellation token to use. - /// , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response StartValidation(string subscriptionId, string resourceGroupName, string watcherName, string healthValidationName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); - - using var message = CreateStartValidationRequest(subscriptionId, resourceGroupName, watcherName, healthValidationName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - case 200: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByParentNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string watcherName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByParentNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string watcherName) - { - 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; } - - /// List HealthValidation resources by Watcher. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListByParentNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByParentNextPageRequest(nextLink, subscriptionId, resourceGroupName, watcherName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - HealthValidationListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = HealthValidationListResult.DeserializeHealthValidationListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List HealthValidation resources by Watcher. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListByParentNextPage(string nextLink, string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByParentNextPageRequest(nextLink, subscriptionId, resourceGroupName, watcherName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - HealthValidationListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = HealthValidationListResult.DeserializeHealthValidationListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/SharedPrivateLinkResourcesRestOperations.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/SharedPrivateLinkResourcesRestOperations.cs index ac495b28a01d..1b76823bdd68 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/SharedPrivateLinkResourcesRestOperations.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/SharedPrivateLinkResourcesRestOperations.cs @@ -6,146 +6,47 @@ #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.DatabaseWatcher.Models; namespace Azure.ResourceManager.DatabaseWatcher { - internal partial class SharedPrivateLinkResourcesRestOperations + internal partial class SharedPrivateLinkResources { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of SharedPrivateLinkResourcesRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public SharedPrivateLinkResourcesRestOperations(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-01-02"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName) - { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/sharedPrivateLinkResources/", false); - uri.AppendPath(sharedPrivateLinkResourceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName) + /// Initializes a new instance of SharedPrivateLinkResources for mocking. + protected SharedPrivateLinkResources() { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/sharedPrivateLinkResources/", false); - uri.AppendPath(sharedPrivateLinkResourceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; } - /// Get a SharedPrivateLinkResource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The Shared Private Link resource name. - /// 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 watcherName, string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) + /// Initializes a new instance of SharedPrivateLinkResources. + /// 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 SharedPrivateLinkResources(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, watcherName, sharedPrivateLinkResourceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DatabaseWatcherSharedPrivateLinkResourceData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DatabaseWatcherSharedPrivateLinkResourceData.DeserializeDatabaseWatcherSharedPrivateLinkResourceData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DatabaseWatcherSharedPrivateLinkResourceData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Get a SharedPrivateLinkResource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The Shared Private Link resource name. - /// 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 watcherName, string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, watcherName, sharedPrivateLinkResourceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DatabaseWatcherSharedPrivateLinkResourceData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DatabaseWatcherSharedPrivateLinkResourceData.DeserializeDatabaseWatcherSharedPrivateLinkResourceData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DatabaseWatcherSharedPrivateLinkResourceData)null, 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 CreateCreateRequestUri(string subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName, DatabaseWatcherSharedPrivateLinkResourceData data) + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); @@ -153,18 +54,20 @@ internal RequestUriBuilder CreateCreateRequestUri(string subscriptionId, string uri.AppendPath("/sharedPrivateLinkResources/", false); uri.AppendPath(sharedPrivateLinkResourceName, 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 CreateCreateRequest(string subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName, DatabaseWatcherSharedPrivateLinkResourceData data) + internal HttpMessage CreateCreateRequest(Guid subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); @@ -172,99 +75,22 @@ internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceG uri.AppendPath("/sharedPrivateLinkResources/", false); uri.AppendPath(sharedPrivateLinkResourceName, 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(data, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Create a SharedPrivateLinkResource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The Shared Private Link resource name. - /// Resource create parameters. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task CreateAsync(string subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName, DatabaseWatcherSharedPrivateLinkResourceData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(subscriptionId, resourceGroupName, watcherName, sharedPrivateLinkResourceName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Create a SharedPrivateLinkResource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The Shared Private Link resource name. - /// Resource create parameters. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response Create(string subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName, DatabaseWatcherSharedPrivateLinkResourceData data, CancellationToken cancellationToken = default) + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(subscriptionId, resourceGroupName, watcherName, sharedPrivateLinkResourceName, data); - _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 watcherName, string sharedPrivateLinkResourceName) - { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/sharedPrivateLinkResources/", false); - uri.AppendPath(sharedPrivateLinkResourceName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); @@ -272,241 +98,43 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath("/sharedPrivateLinkResources/", false); uri.AppendPath(sharedPrivateLinkResourceName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Delete a SharedPrivateLinkResource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The Shared Private Link resource name. - /// 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 watcherName, string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, watcherName, sharedPrivateLinkResourceName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a SharedPrivateLinkResource. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The Shared Private Link resource name. - /// 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 watcherName, string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, watcherName, sharedPrivateLinkResourceName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByWatcherRequestUri(string subscriptionId, string resourceGroupName, string watcherName) + internal HttpMessage CreateGetByWatcherRequest(Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/sharedPrivateLinkResources", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListByWatcherRequest(string subscriptionId, string resourceGroupName, string watcherName) - { - 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(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); uri.AppendPath(watcherName, true); uri.AppendPath("/sharedPrivateLinkResources", 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 SharedPrivateLinkResource resources by Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListByWatcherAsync(string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetByWatcherRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByWatcherRequest(subscriptionId, resourceGroupName, watcherName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SharedPrivateLinkResourceListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SharedPrivateLinkResourceListResult.DeserializeSharedPrivateLinkResourceListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List SharedPrivateLinkResource resources by Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListByWatcher(string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByWatcherRequest(subscriptionId, resourceGroupName, watcherName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SharedPrivateLinkResourceListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SharedPrivateLinkResourceListResult.DeserializeSharedPrivateLinkResourceListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByWatcherNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string watcherName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByWatcherNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string watcherName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + 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 SharedPrivateLinkResource resources by Watcher. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListByWatcherNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByWatcherNextPageRequest(nextLink, subscriptionId, resourceGroupName, watcherName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - SharedPrivateLinkResourceListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = SharedPrivateLinkResourceListResult.DeserializeSharedPrivateLinkResourceListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List SharedPrivateLinkResource resources by Watcher. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListByWatcherNextPage(string nextLink, string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByWatcherNextPageRequest(nextLink, subscriptionId, resourceGroupName, watcherName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - SharedPrivateLinkResourceListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = SharedPrivateLinkResourceListResult.DeserializeSharedPrivateLinkResourceListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/TargetsRestOperations.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/TargetsRestOperations.cs index 2be61107a0d2..9820bde192a1 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/TargetsRestOperations.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/TargetsRestOperations.cs @@ -6,146 +6,47 @@ #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.DatabaseWatcher.Models; namespace Azure.ResourceManager.DatabaseWatcher { - internal partial class TargetsRestOperations + internal partial class Targets { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of TargetsRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public TargetsRestOperations(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-01-02"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string watcherName, string targetName) - { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/targets/", false); - uri.AppendPath(targetName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string watcherName, string targetName) + /// Initializes a new instance of Targets for mocking. + protected Targets() { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/targets/", false); - uri.AppendPath(targetName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; } - /// Get a Target. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The target resource name. - /// 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 watcherName, string targetName, CancellationToken cancellationToken = default) + /// Initializes a new instance of Targets. + /// 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 Targets(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, watcherName, targetName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DatabaseWatcherTargetData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DatabaseWatcherTargetData.DeserializeDatabaseWatcherTargetData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DatabaseWatcherTargetData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Get a Target. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The target resource name. - /// 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 watcherName, string targetName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, watcherName, targetName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DatabaseWatcherTargetData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DatabaseWatcherTargetData.DeserializeDatabaseWatcherTargetData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DatabaseWatcherTargetData)null, 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 CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string watcherName, string targetName, DatabaseWatcherTargetData data) + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string watcherName, string targetName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); @@ -153,18 +54,20 @@ internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, uri.AppendPath("/targets/", false); uri.AppendPath(targetName, 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 CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string watcherName, string targetName, DatabaseWatcherTargetData data) + internal HttpMessage CreateCreateOrUpdateRequest(Guid subscriptionId, string resourceGroupName, string watcherName, string targetName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); @@ -172,109 +75,22 @@ internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string r uri.AppendPath("/targets/", false); uri.AppendPath(targetName, 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(data, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Create a Target. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The target resource name. - /// Resource create parameters. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public async Task> CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string watcherName, string targetName, DatabaseWatcherTargetData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, watcherName, targetName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - { - DatabaseWatcherTargetData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DatabaseWatcherTargetData.DeserializeDatabaseWatcherTargetData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Create a Target. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The target resource name. - /// Resource create parameters. - /// The cancellation token to use. - /// , , , or is null. - /// , , or is an empty string, and was expected to be non-empty. - public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string watcherName, string targetName, DatabaseWatcherTargetData data, CancellationToken cancellationToken = default) + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string watcherName, string targetName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, watcherName, targetName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - { - DatabaseWatcherTargetData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DatabaseWatcherTargetData.DeserializeDatabaseWatcherTargetData(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string watcherName, string targetName) - { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/targets/", false); - uri.AppendPath(targetName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string watcherName, string targetName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); @@ -282,241 +98,43 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath("/targets/", false); uri.AppendPath(targetName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Delete a Target. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The target resource name. - /// 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 watcherName, string targetName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, watcherName, targetName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a Target. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The target resource name. - /// 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 watcherName, string targetName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, watcherName, targetName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByWatcherRequestUri(string subscriptionId, string resourceGroupName, string watcherName) + internal HttpMessage CreateGetByWatcherRequest(Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/targets", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListByWatcherRequest(string subscriptionId, string resourceGroupName, string watcherName) - { - 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(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); uri.AppendPath(watcherName, true); uri.AppendPath("/targets", 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 Target resources by Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListByWatcherAsync(string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetByWatcherRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByWatcherRequest(subscriptionId, resourceGroupName, watcherName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TargetListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TargetListResult.DeserializeTargetListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List Target resources by Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListByWatcher(string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByWatcherRequest(subscriptionId, resourceGroupName, watcherName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TargetListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TargetListResult.DeserializeTargetListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByWatcherNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string watcherName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByWatcherNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string watcherName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + 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 Target resources by Watcher. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListByWatcherNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByWatcherNextPageRequest(nextLink, subscriptionId, resourceGroupName, watcherName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - TargetListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = TargetListResult.DeserializeTargetListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List Target resources by Watcher. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListByWatcherNextPage(string nextLink, string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateListByWatcherNextPageRequest(nextLink, subscriptionId, resourceGroupName, watcherName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - TargetListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = TargetListResult.DeserializeTargetListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/WatchersRestOperations.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/WatchersRestOperations.cs index 12bfd8a16eea..249362a46a16 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/WatchersRestOperations.cs +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/WatchersRestOperations.cs @@ -6,889 +6,216 @@ #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.DatabaseWatcher.Models; namespace Azure.ResourceManager.DatabaseWatcher { - internal partial class WatchersRestOperations + internal partial class Watchers { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of WatchersRestOperations. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The application id to use for user agent. - /// Service host. - /// The API version to use for this operation. - /// or is null. - public WatchersRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + /// Initializes a new instance of Watchers for mocking. + protected Watchers() { - _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); - _endpoint = endpoint ?? new Uri("https://management.azure.com"); - _apiVersion = apiVersion ?? "2025-01-02"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string watcherName) - { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string watcherName) - { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Get a Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// 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 watcherName, CancellationToken cancellationToken = default) + /// Initializes a new instance of Watchers. + /// 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 Watchers(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, watcherName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - DatabaseWatcherData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = DatabaseWatcherData.DeserializeDatabaseWatcherData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DatabaseWatcherData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Get a Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// 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 watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateGetRequest(subscriptionId, resourceGroupName, watcherName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - DatabaseWatcherData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = DatabaseWatcherData.DeserializeDatabaseWatcherData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((DatabaseWatcherData)null, 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 CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string watcherName, DatabaseWatcherData data) + internal HttpMessage CreateGetRequest(Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); uri.AppendPath(watcherName, 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 CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string watcherName, DatabaseWatcherData data) + internal HttpMessage CreateCreateOrUpdateRequest(Guid subscriptionId, string resourceGroupName, string watcherName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); uri.AppendPath(watcherName, 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(data, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Create a Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// Resource create parameters. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string watcherName, DatabaseWatcherData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, watcherName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Create a Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// Resource create parameters. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string watcherName, DatabaseWatcherData data, CancellationToken cancellationToken = default) + internal HttpMessage CreateUpdateRequest(Guid subscriptionId, string resourceGroupName, string watcherName, RequestContent content, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, watcherName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string watcherName, DatabaseWatcherPatch patch) - { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string watcherName, DatabaseWatcherPatch patch) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Patch; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); uri.AppendPath(watcherName, 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; } - /// Update a Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The resource properties to be updated. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string watcherName, DatabaseWatcherPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, watcherName, patch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 202: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Update a Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The resource properties to be updated. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Update(string subscriptionId, string resourceGroupName, string watcherName, DatabaseWatcherPatch patch, CancellationToken cancellationToken = default) + internal HttpMessage CreateDeleteRequest(Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, watcherName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 202: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string watcherName) - { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string watcherName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); uri.AppendPath(watcherName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - _userAgent.Apply(message); + request.Method = RequestMethod.Delete; return message; } - /// Delete a Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// 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 watcherName, CancellationToken cancellationToken = default) + internal HttpMessage CreateGetByResourceGroupRequest(Guid subscriptionId, string resourceGroupName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, watcherName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a Watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// 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 watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, watcherName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers", 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(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers", 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 Watcher resources by resource group. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - WatcherListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = WatcherListResult.DeserializeWatcherListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List Watcher resources by resource group. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetByResourceGroupRequest(Uri nextPage, Guid subscriptionId, string resourceGroupName, RequestContext context) { - 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: - { - WatcherListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = WatcherListResult.DeserializeWatcherListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers", 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 CreateListBySubscriptionRequest(string subscriptionId) + internal HttpMessage CreateGetBySubscriptionRequest(Guid subscriptionId, 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); + uri.AppendPath(subscriptionId.ToString(), true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers", 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 Watcher resources by subscription ID. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListBySubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetBySubscriptionRequest(Uri nextPage, Guid subscriptionId, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionRequest(subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - WatcherListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = WatcherListResult.DeserializeWatcherListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List Watcher resources by subscription ID. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public Response ListBySubscription(string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionRequest(subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - WatcherListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = WatcherListResult.DeserializeWatcherListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateStartRequestUri(string subscriptionId, string resourceGroupName, string watcherName) - { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/start", 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 CreateStartRequest(string subscriptionId, string resourceGroupName, string watcherName) + internal HttpMessage CreateStartRequest(Guid subscriptionId, string resourceGroupName, string watcherName, 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(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); uri.AppendPath(watcherName, true); uri.AppendPath("/start", 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.Post; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// The action to start monitoring all targets configured for a database watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task StartAsync(string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateStartRequest(subscriptionId, resourceGroupName, watcherName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - case 200: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// The action to start monitoring all targets configured for a database watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Start(string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateStartRequest(subscriptionId, resourceGroupName, watcherName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - case 200: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateStopRequestUri(string subscriptionId, string resourceGroupName, string watcherName) - { - 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.DatabaseWatcher/watchers/", false); - uri.AppendPath(watcherName, true); - uri.AppendPath("/stop", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateStopRequest(string subscriptionId, string resourceGroupName, string watcherName) + internal HttpMessage CreateStopRequest(Guid subscriptionId, string resourceGroupName, string watcherName, 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(subscriptionId.ToString(), true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); uri.AppendPath(watcherName, true); uri.AppendPath("/stop", 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; - } - - /// The action to stop monitoring all targets configured for a database watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task StopAsync(string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateStopRequest(subscriptionId, resourceGroupName, watcherName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 202: - case 200: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// The action to stop monitoring all targets configured for a database watcher. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The database watcher name. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Stop(string subscriptionId, string resourceGroupName, string watcherName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); - - using var message = CreateStopRequest(subscriptionId, resourceGroupName, watcherName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 202: - case 200: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// List Watcher resources by resource group. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> ListByResourceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - WatcherListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = WatcherListResult.DeserializeWatcherListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List Watcher resources by resource group. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The name of the resource group. The name is case insensitive. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response ListByResourceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - WatcherListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = WatcherListResult.DeserializeWatcherListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); return message; } - - /// List Watcher resources by subscription ID. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - WatcherListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = WatcherListResult.DeserializeWatcherListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List Watcher resources by subscription ID. - /// The URL to the next page of results. - /// The ID of the target subscription. The value must be an UUID. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - WatcherListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = WatcherListResult.DeserializeWatcherListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourcesGetByWatcherAsyncCollectionResultOfT.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourcesGetByWatcherAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..f38cbf12dc07 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourcesGetByWatcherAsyncCollectionResultOfT.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class SharedPrivateLinkResourcesGetByWatcherAsyncCollectionResultOfT : AsyncPageable + { + private readonly SharedPrivateLinkResources _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _watcherName; + private readonly RequestContext _context; + + /// Initializes a new instance of SharedPrivateLinkResourcesGetByWatcherAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The SharedPrivateLinkResources 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 database watcher name. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public SharedPrivateLinkResourcesGetByWatcherAsyncCollectionResultOfT(SharedPrivateLinkResources client, Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _watcherName = watcherName; + _context = context; + } + + /// Gets the pages of SharedPrivateLinkResourcesGetByWatcherAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of SharedPrivateLinkResourcesGetByWatcherAsyncCollectionResultOfT 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; + } + SharedPrivateLinkResourceListResult result = SharedPrivateLinkResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)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.CreateNextGetByWatcherRequest(nextLink, _subscriptionId, _resourceGroupName, _watcherName, _context) : _client.CreateGetByWatcherRequest(_subscriptionId, _resourceGroupName, _watcherName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourcesGetByWatcherCollectionResultOfT.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourcesGetByWatcherCollectionResultOfT.cs new file mode 100644 index 000000000000..1cf9ebdef40b --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourcesGetByWatcherCollectionResultOfT.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class SharedPrivateLinkResourcesGetByWatcherCollectionResultOfT : Pageable + { + private readonly SharedPrivateLinkResources _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _watcherName; + private readonly RequestContext _context; + + /// Initializes a new instance of SharedPrivateLinkResourcesGetByWatcherCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The SharedPrivateLinkResources 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 database watcher name. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public SharedPrivateLinkResourcesGetByWatcherCollectionResultOfT(SharedPrivateLinkResources client, Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _watcherName = watcherName; + _context = context; + } + + /// Gets the pages of SharedPrivateLinkResourcesGetByWatcherCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of SharedPrivateLinkResourcesGetByWatcherCollectionResultOfT 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; + } + SharedPrivateLinkResourceListResult result = SharedPrivateLinkResourceListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)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.CreateNextGetByWatcherRequest(nextLink, _subscriptionId, _resourceGroupName, _watcherName, _context) : _client.CreateGetByWatcherRequest(_subscriptionId, _resourceGroupName, _watcherName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DatabaseWatcherSharedPrivateLinkResourceCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetsGetByWatcherAsyncCollectionResultOfT.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetsGetByWatcherAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..27cdba640d3d --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetsGetByWatcherAsyncCollectionResultOfT.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class TargetsGetByWatcherAsyncCollectionResultOfT : AsyncPageable + { + private readonly Targets _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _watcherName; + private readonly RequestContext _context; + + /// Initializes a new instance of TargetsGetByWatcherAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Targets 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 database watcher name. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public TargetsGetByWatcherAsyncCollectionResultOfT(Targets client, Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _watcherName = watcherName; + _context = context; + } + + /// Gets the pages of TargetsGetByWatcherAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of TargetsGetByWatcherAsyncCollectionResultOfT 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; + } + TargetListResult result = TargetListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)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.CreateNextGetByWatcherRequest(nextLink, _subscriptionId, _resourceGroupName, _watcherName, _context) : _client.CreateGetByWatcherRequest(_subscriptionId, _resourceGroupName, _watcherName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetsGetByWatcherCollectionResultOfT.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetsGetByWatcherCollectionResultOfT.cs new file mode 100644 index 000000000000..f089f2dcde78 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetsGetByWatcherCollectionResultOfT.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class TargetsGetByWatcherCollectionResultOfT : Pageable + { + private readonly Targets _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly string _watcherName; + private readonly RequestContext _context; + + /// Initializes a new instance of TargetsGetByWatcherCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Targets 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 database watcher name. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public TargetsGetByWatcherCollectionResultOfT(Targets client, Guid subscriptionId, string resourceGroupName, string watcherName, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _watcherName = watcherName; + _context = context; + } + + /// Gets the pages of TargetsGetByWatcherCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of TargetsGetByWatcherCollectionResultOfT 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; + } + TargetListResult result = TargetListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)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.CreateNextGetByWatcherRequest(nextLink, _subscriptionId, _resourceGroupName, _watcherName, _context) : _client.CreateGetByWatcherRequest(_subscriptionId, _resourceGroupName, _watcherName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("DatabaseWatcherTargetCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatchersGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatchersGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..f3ba71eebf8d --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatchersGetByResourceGroupAsyncCollectionResultOfT.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class WatchersGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly Watchers _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of WatchersGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Watchers 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. + /// is null. + /// is an empty string, and was expected to be non-empty. + public WatchersGetByResourceGroupAsyncCollectionResultOfT(Watchers client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of WatchersGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of WatchersGetByResourceGroupAsyncCollectionResultOfT 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; + } + WatcherListResult result = WatcherListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)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("DatabaseWatcherCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatchersGetByResourceGroupCollectionResultOfT.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatchersGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..6a803ac35736 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatchersGetByResourceGroupCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class WatchersGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly Watchers _client; + private readonly Guid _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of WatchersGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Watchers 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. + /// is null. + /// is an empty string, and was expected to be non-empty. + public WatchersGetByResourceGroupCollectionResultOfT(Watchers client, Guid subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of WatchersGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of WatchersGetByResourceGroupCollectionResultOfT 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; + } + WatcherListResult result = WatcherListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)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("DatabaseWatcherCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatchersGetBySubscriptionAsyncCollectionResultOfT.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatchersGetBySubscriptionAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..ed859a21465d --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatchersGetBySubscriptionAsyncCollectionResultOfT.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.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class WatchersGetBySubscriptionAsyncCollectionResultOfT : AsyncPageable + { + private readonly Watchers _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of WatchersGetBySubscriptionAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Watchers 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 WatchersGetBySubscriptionAsyncCollectionResultOfT(Watchers client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of WatchersGetBySubscriptionAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of WatchersGetBySubscriptionAsyncCollectionResultOfT 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; + } + WatcherListResult result = WatcherListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)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.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableDatabaseWatcherSubscriptionResource.GetDatabaseWatchers"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatchersGetBySubscriptionCollectionResultOfT.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatchersGetBySubscriptionCollectionResultOfT.cs new file mode 100644 index 000000000000..86f4dec9432c --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatchersGetBySubscriptionCollectionResultOfT.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.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class WatchersGetBySubscriptionCollectionResultOfT : Pageable + { + private readonly Watchers _client; + private readonly Guid _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of WatchersGetBySubscriptionCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Watchers 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 WatchersGetBySubscriptionCollectionResultOfT(Watchers client, Guid subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of WatchersGetBySubscriptionCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of WatchersGetBySubscriptionCollectionResultOfT 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; + } + WatcherListResult result = WatcherListResult.FromResponse(response); + yield return Page.FromValues((IReadOnlyList)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.CreateNextGetBySubscriptionRequest(nextLink, _subscriptionId, _context) : _client.CreateGetBySubscriptionRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableDatabaseWatcherSubscriptionResource.GetDatabaseWatchers"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tsp-location.yaml b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tsp-location.yaml index f961eccf3a32..c5007458f84f 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tsp-location.yaml +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tsp-location.yaml @@ -1,3 +1,4 @@ directory: specification/databasewatcher/DatabaseWatcher.Management -commit: 6267b64842af3d744c5b092a3f3beef49729ad6d +commit: 5726a1414285a8525540c78116372d2254205be2 repo: Azure/azure-rest-api-specs +emitterPackageJsonPath: "eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json"