diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/Azure.ResourceManager.DatabaseWatcher.sln b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/Azure.ResourceManager.DatabaseWatcher.sln new file mode 100644 index 000000000000..313caa46f33f --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/Azure.ResourceManager.DatabaseWatcher.sln @@ -0,0 +1,56 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.ResourceManager.DatabaseWatcher.Samples", "samples\Azure.ResourceManager.DatabaseWatcher.Samples.csproj", "{7A2DFF15-5746-49F4-BD0F-C6C35337088A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.DatabaseWatcher", "src\Azure.ResourceManager.DatabaseWatcher.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.DatabaseWatcher.Tests", "tests\Azure.ResourceManager.DatabaseWatcher.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/CHANGELOG.md b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes \ No newline at end of file diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/Directory.Build.props b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/README.md b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/README.md new file mode 100644 index 000000000000..876bc6678452 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/README.md @@ -0,0 +1,80 @@ +# Microsoft Azure DatabaseWatcher management client library for .NET + +**[Describe the service briefly first.]** + +This library follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: + + - Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET. + - Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. + - HTTP pipeline with custom policies. + - Better error-handling. + - Support uniform telemetry across all languages. + +## Getting started + +### Install the package + +Install the Microsoft Azure DatabaseWatcher management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.DatabaseWatcher --prerelease +``` + +### Prerequisites + +* You must have an [Microsoft Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +To create an authenticated client and start interacting with Microsoft Azure resources, see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). + +## Key concepts + +Key concepts of the Microsoft Azure SDK for .NET can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html) + +## Documentation + +Documentation is available to help you learn how to use this package: + +- [Quickstart](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). +- [API References](https://learn.microsoft.com/dotnet/api/?view=azure-dotnet). +- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md). + +## Examples + +Code samples for using the management library for .NET can be found in the following locations +- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples) + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +For more information about Microsoft Azure SDK, see [this website](https://azure.github.io/azure-sdk/). + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ \ No newline at end of file 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 new file mode 100644 index 000000000000..600b1aa1b45a --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/api/Azure.ResourceManager.DatabaseWatcher.net8.0.cs @@ -0,0 +1,691 @@ +namespace Azure.ResourceManager.DatabaseWatcher +{ + public partial class AlertRuleResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected AlertRuleResource() { } + public virtual Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData 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.AlertRuleResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class AlertRuleResourceCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected AlertRuleResourceCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string alertRuleResourceName, Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string alertRuleResourceName, Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class AlertRuleResourceData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AlertRuleResourceData() { } + public Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleResourceProperties Properties { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData 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.AlertRuleResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public static partial class DatabaseWatcherExtensions + { + public static Azure.ResourceManager.DatabaseWatcher.AlertRuleResource GetAlertRuleResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.HealthValidationResource GetHealthValidationResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResource GetSharedPrivateLinkResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.TargetResource GetTargetResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.Response GetWatcher(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetWatcherAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.WatcherResource GetWatcherResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.WatcherCollection GetWatchers(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } + public static Azure.Pageable GetWatchers(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetWatchersAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class HealthValidationCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected HealthValidationCollection() { } + public virtual Azure.Response Exists(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class HealthValidationData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal HealthValidationData() { } + public Azure.ResourceManager.DatabaseWatcher.Models.HealthValidationProperties Properties { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.HealthValidationData 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.HealthValidationData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class HealthValidationResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected HealthValidationResource() { } + public virtual Azure.ResourceManager.DatabaseWatcher.HealthValidationData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string healthValidationName) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation StartValidation(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> StartValidationAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.DatabaseWatcher.HealthValidationData 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.HealthValidationData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class SharedPrivateLinkResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected SharedPrivateLinkResource() { } + public virtual Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData 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.SharedPrivateLinkResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class SharedPrivateLinkResourceCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected SharedPrivateLinkResourceCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string sharedPrivateLinkResourceName, Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string sharedPrivateLinkResourceName, Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class SharedPrivateLinkResourceData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SharedPrivateLinkResourceData() { } + public Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceProperties Properties { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData 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.SharedPrivateLinkResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TargetCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected TargetCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string targetName, Azure.ResourceManager.DatabaseWatcher.TargetData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string targetName, Azure.ResourceManager.DatabaseWatcher.TargetData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class TargetData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TargetData() { } + public Azure.ResourceManager.DatabaseWatcher.Models.TargetProperties Properties { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.TargetData 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.TargetData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TargetResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected TargetResource() { } + public virtual Azure.ResourceManager.DatabaseWatcher.TargetData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string targetName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.DatabaseWatcher.TargetData 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.TargetData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.TargetData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.TargetData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class WatcherCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected WatcherCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string watcherName, Azure.ResourceManager.DatabaseWatcher.WatcherData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string watcherName, Azure.ResourceManager.DatabaseWatcher.WatcherData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class WatcherData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public WatcherData(Azure.Core.AzureLocation location) { } + public Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityV4 Identity { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.WatcherProperties Properties { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.WatcherData 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.WatcherData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class WatcherResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected WatcherResource() { } + public virtual Azure.ResourceManager.DatabaseWatcher.WatcherData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetAlertRuleResource(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAlertRuleResourceAsync(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceCollection GetAlertRuleResources() { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetHealthValidation(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetHealthValidationAsync(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.HealthValidationCollection GetHealthValidations() { throw null; } + public virtual Azure.Response GetSharedPrivateLinkResource(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetSharedPrivateLinkResourceAsync(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceCollection GetSharedPrivateLinkResources() { throw null; } + public virtual Azure.Response GetTarget(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTargetAsync(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.TargetCollection GetTargets() { throw null; } + public virtual Azure.Response RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SetTagsAsync(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Start(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task StartAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Stop(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task StopAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.DatabaseWatcher.WatcherData 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.WatcherData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.Models.WatcherPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.Models.WatcherPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } +} +namespace Azure.ResourceManager.DatabaseWatcher.Mocking +{ + public partial class MockableDatabaseWatcherArmClient : Azure.ResourceManager.ArmResource + { + protected MockableDatabaseWatcherArmClient() { } + public virtual Azure.ResourceManager.DatabaseWatcher.AlertRuleResource GetAlertRuleResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.HealthValidationResource GetHealthValidationResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResource GetSharedPrivateLinkResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.TargetResource GetTargetResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.WatcherResource GetWatcherResource(Azure.Core.ResourceIdentifier id) { throw null; } + } + public partial class MockableDatabaseWatcherResourceGroupResource : Azure.ResourceManager.ArmResource + { + protected MockableDatabaseWatcherResourceGroupResource() { } + public virtual Azure.Response GetWatcher(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetWatcherAsync(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.WatcherCollection GetWatchers() { throw null; } + } + public partial class MockableDatabaseWatcherSubscriptionResource : Azure.ResourceManager.ArmResource + { + protected MockableDatabaseWatcherSubscriptionResource() { } + public virtual Azure.Pageable GetWatchers(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetWatchersAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } +} +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AlertRuleCreationProperty : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AlertRuleCreationProperty(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty CreatedWithActionGroup { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty None { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + 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 bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty left, Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty right) { throw null; } + public override string ToString() { throw null; } + } + public partial class AlertRuleResourceProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AlertRuleResourceProperties(Azure.Core.ResourceIdentifier alertRuleResourceId, Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty createdWithProperties, System.DateTimeOffset createdOn, string alertRuleTemplateId, string alertRuleTemplateVersion) { } + public Azure.Core.ResourceIdentifier AlertRuleResourceId { get { throw null; } set { } } + public string AlertRuleTemplateId { get { throw null; } set { } } + public string AlertRuleTemplateVersion { get { throw null; } set { } } + public System.DateTimeOffset CreatedOn { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty CreatedWithProperties { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? ProvisioningState { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleResourceProperties 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.AlertRuleResourceProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public static partial class ArmDatabaseWatcherModelFactory + { + public static Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData AlertRuleResourceData(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.AlertRuleResourceProperties properties = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleResourceProperties AlertRuleResourceProperties(Azure.Core.ResourceIdentifier alertRuleResourceId = null, Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty createdWithProperties = default(Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty), System.DateTimeOffset createdOn = default(System.DateTimeOffset), Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState?), string alertRuleTemplateId = null, string alertRuleTemplateVersion = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.HealthValidationData HealthValidationData(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.HealthValidationProperties properties = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.HealthValidationProperties HealthValidationProperties(System.DateTimeOffset startOn = default(System.DateTimeOffset), System.DateTimeOffset endOn = default(System.DateTimeOffset), Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus status = default(Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus), System.Collections.Generic.IEnumerable issues = null, Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState?)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityV4 ManagedServiceIdentityV4(System.Guid? principalId = default(System.Guid?), System.Guid? tenantId = default(System.Guid?), Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType type = default(Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType), System.Collections.Generic.IDictionary userAssignedIdentities = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData SharedPrivateLinkResourceData(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.SharedPrivateLinkResourceProperties properties = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceProperties SharedPrivateLinkResourceProperties(Azure.Core.ResourceIdentifier privateLinkResourceId = null, string groupId = null, string requestMessage = null, string dnsZone = null, Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus? status = default(Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus?), Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState?)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.SqlDbElasticPoolTargetProperties SqlDbElasticPoolTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType = default(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType), Azure.ResourceManager.DatabaseWatcher.Models.VaultSecret targetVault = null, string connectionServerName = null, Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState?), Azure.Core.ResourceIdentifier sqlEpResourceId = null, Azure.Core.ResourceIdentifier anchorDatabaseResourceId = null, bool? readIntent = default(bool?)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.SqlDbSingleDatabaseTargetProperties SqlDbSingleDatabaseTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType = default(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType), Azure.ResourceManager.DatabaseWatcher.Models.VaultSecret targetVault = null, string connectionServerName = null, Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState?), Azure.Core.ResourceIdentifier sqlDbResourceId = null, bool? readIntent = default(bool?)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.SqlMiTargetProperties SqlMiTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType = default(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType), Azure.ResourceManager.DatabaseWatcher.Models.VaultSecret targetVault = null, string connectionServerName = null, Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState?), Azure.Core.ResourceIdentifier sqlMiResourceId = null, int? connectionTcpPort = default(int?), bool? readIntent = default(bool?)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.TargetData TargetData(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.TargetProperties properties = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.TargetProperties TargetProperties(string targetType = null, Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType = default(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType), Azure.ResourceManager.DatabaseWatcher.Models.VaultSecret targetVault = null, string connectionServerName = null, Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState?)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.ValidationIssue ValidationIssue(string errorCode = null, string errorMessage = null, string additionalDetails = null, string recommendationMessage = null, System.Uri recommendationUri = null, Azure.Core.ResourceIdentifier relatedResourceId = null, string relatedResourceType = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.WatcherData WatcherData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.DatabaseWatcher.Models.WatcherProperties properties = null, Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityV4 identity = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.WatcherProperties WatcherProperties(Azure.ResourceManager.DatabaseWatcher.Models.Datastore datastore = null, Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus? status = default(Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus?), Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState?), Azure.Core.ResourceIdentifier defaultAlertRuleIdentityResourceId = null) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct DatabaseWatcherProvisioningState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public DatabaseWatcherProvisioningState(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState Canceled { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState Failed { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState Succeeded { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + 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 bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState right) { throw null; } + public override string ToString() { throw null; } + } + public partial class Datastore : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public Datastore(string kustoClusterUri, string kustoDataIngestionUri, string kustoDatabaseName, string kustoManagementUri, Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType kustoOfferingType) { } + public Azure.Core.ResourceIdentifier AdxClusterResourceId { get { throw null; } set { } } + public string KustoClusterDisplayName { get { throw null; } set { } } + public string KustoClusterUri { get { throw null; } set { } } + public string KustoDatabaseName { get { throw null; } set { } } + public string KustoDataIngestionUri { get { throw null; } set { } } + public string KustoManagementUri { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType KustoOfferingType { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.Datastore 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.Datastore System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class HealthValidationProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal HealthValidationProperties() { } + public System.DateTimeOffset EndOn { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Issues { get { throw null; } } + public Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? ProvisioningState { get { throw null; } } + public System.DateTimeOffset StartOn { get { throw null; } } + public Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus Status { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.HealthValidationProperties 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.HealthValidationProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct KustoOfferingType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public KustoOfferingType(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType Adx { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType Fabric { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType Free { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + 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 bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType left, Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ManagedServiceIdentityType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ManagedServiceIdentityType(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType None { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType SystemAndUserAssigned { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType SystemAssigned { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType UserAssigned { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType left, Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType right) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType left, Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class ManagedServiceIdentityV4 : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ManagedServiceIdentityV4(Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType type) { } + public System.Guid? PrincipalId { get { throw null; } } + public System.Guid? TenantId { get { throw null; } } + public Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType Type { get { throw null; } set { } } + public System.Collections.Generic.IDictionary UserAssignedIdentities { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityV4 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.ManagedServiceIdentityV4 System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ResourceProvisioningState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ResourceProvisioningState(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState Canceled { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState Failed { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState Succeeded { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState left, Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState right) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState left, Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState right) { throw null; } + public override string ToString() { throw null; } + } + public partial class SharedPrivateLinkResourceProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SharedPrivateLinkResourceProperties(Azure.Core.ResourceIdentifier privateLinkResourceId, string groupId, string requestMessage) { } + public string DnsZone { get { throw null; } set { } } + public string GroupId { get { throw null; } set { } } + public Azure.Core.ResourceIdentifier PrivateLinkResourceId { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? ProvisioningState { get { throw null; } } + public string RequestMessage { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus? Status { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceProperties 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.SharedPrivateLinkResourceProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct SharedPrivateLinkResourceStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public SharedPrivateLinkResourceStatus(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus Approved { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus Disconnected { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus Pending { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus Rejected { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus left, Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus right) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus left, Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class SqlDbElasticPoolTargetProperties : Azure.ResourceManager.DatabaseWatcher.Models.TargetProperties, 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 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 void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + 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; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class SqlDbSingleDatabaseTargetProperties : Azure.ResourceManager.DatabaseWatcher.Models.TargetProperties, 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 bool? ReadIntent { get { throw null; } set { } } + public Azure.Core.ResourceIdentifier SqlDbResourceId { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + 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; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class SqlMiTargetProperties : Azure.ResourceManager.DatabaseWatcher.Models.TargetProperties, 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 int? ConnectionTcpPort { get { throw null; } set { } } + public bool? ReadIntent { get { throw null; } set { } } + public Azure.Core.ResourceIdentifier SqlMiResourceId { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + 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; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct TargetAuthenticationType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public TargetAuthenticationType(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType Aad { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType Sql { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + 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 bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType left, Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType right) { throw null; } + public override string ToString() { throw null; } + } + public abstract partial class TargetProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + protected TargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName) { } + public string ConnectionServerName { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? ProvisioningState { get { throw null; } } + public Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType TargetAuthenticationType { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.VaultSecret TargetVault { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.TargetProperties 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.TargetProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ValidationIssue : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ValidationIssue() { } + public string AdditionalDetails { get { throw null; } } + public string ErrorCode { get { throw null; } } + public string ErrorMessage { get { throw null; } } + public string RecommendationMessage { get { throw null; } } + public System.Uri RecommendationUri { get { throw null; } } + public Azure.Core.ResourceIdentifier RelatedResourceId { get { throw null; } } + public string RelatedResourceType { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.ValidationIssue 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.ValidationIssue System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ValidationStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ValidationStatus(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus Canceled { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus Failed { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus NotStarted { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus Running { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus Succeeded { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus TimedOut { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus left, Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus right) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus left, Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class VaultSecret : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public VaultSecret() { } + 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 void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.VaultSecret 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.VaultSecret System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class WatcherPatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public WatcherPatch() { } + public Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityV4 Identity { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.WatcherUpdateProperties Properties { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.WatcherPatch 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.WatcherPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class WatcherProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public WatcherProperties() { } + public Azure.ResourceManager.DatabaseWatcher.Models.Datastore Datastore { get { throw null; } set { } } + public Azure.Core.ResourceIdentifier DefaultAlertRuleIdentityResourceId { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState? ProvisioningState { get { throw null; } } + public Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus? Status { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.WatcherProperties 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.WatcherProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct WatcherStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public WatcherStatus(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus Deleting { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus Running { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus Starting { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus Stopped { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus Stopping { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus left, Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus right) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus left, Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class WatcherUpdateProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public WatcherUpdateProperties() { } + public Azure.ResourceManager.DatabaseWatcher.Models.Datastore Datastore { get { throw null; } set { } } + public Azure.Core.ResourceIdentifier DefaultAlertRuleIdentityResourceId { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.WatcherUpdateProperties 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.WatcherUpdateProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(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 new file mode 100644 index 000000000000..600b1aa1b45a --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/api/Azure.ResourceManager.DatabaseWatcher.netstandard2.0.cs @@ -0,0 +1,691 @@ +namespace Azure.ResourceManager.DatabaseWatcher +{ + public partial class AlertRuleResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected AlertRuleResource() { } + public virtual Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData 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.AlertRuleResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class AlertRuleResourceCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected AlertRuleResourceCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string alertRuleResourceName, Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string alertRuleResourceName, Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class AlertRuleResourceData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AlertRuleResourceData() { } + public Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleResourceProperties Properties { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData 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.AlertRuleResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public static partial class DatabaseWatcherExtensions + { + public static Azure.ResourceManager.DatabaseWatcher.AlertRuleResource GetAlertRuleResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.HealthValidationResource GetHealthValidationResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResource GetSharedPrivateLinkResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.TargetResource GetTargetResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.Response GetWatcher(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> GetWatcherAsync(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource, string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.WatcherResource GetWatcherResource(this Azure.ResourceManager.ArmClient client, Azure.Core.ResourceIdentifier id) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.WatcherCollection GetWatchers(this Azure.ResourceManager.Resources.ResourceGroupResource resourceGroupResource) { throw null; } + public static Azure.Pageable GetWatchers(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.AsyncPageable GetWatchersAsync(this Azure.ResourceManager.Resources.SubscriptionResource subscriptionResource, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class HealthValidationCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected HealthValidationCollection() { } + public virtual Azure.Response Exists(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class HealthValidationData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal HealthValidationData() { } + public Azure.ResourceManager.DatabaseWatcher.Models.HealthValidationProperties Properties { get { throw null; } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.HealthValidationData 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.HealthValidationData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class HealthValidationResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected HealthValidationResource() { } + public virtual Azure.ResourceManager.DatabaseWatcher.HealthValidationData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string healthValidationName) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation StartValidation(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> StartValidationAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.DatabaseWatcher.HealthValidationData 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.HealthValidationData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class SharedPrivateLinkResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected SharedPrivateLinkResource() { } + public virtual Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData 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.SharedPrivateLinkResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class SharedPrivateLinkResourceCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected SharedPrivateLinkResourceCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string sharedPrivateLinkResourceName, Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string sharedPrivateLinkResourceName, Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class SharedPrivateLinkResourceData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SharedPrivateLinkResourceData() { } + public Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceProperties Properties { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData 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.SharedPrivateLinkResourceData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TargetCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected TargetCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string targetName, Azure.ResourceManager.DatabaseWatcher.TargetData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string targetName, Azure.ResourceManager.DatabaseWatcher.TargetData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class TargetData : Azure.ResourceManager.Models.ResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TargetData() { } + public Azure.ResourceManager.DatabaseWatcher.Models.TargetProperties Properties { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.TargetData 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.TargetData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TargetResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected TargetResource() { } + public virtual Azure.ResourceManager.DatabaseWatcher.TargetData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName, string targetName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.DatabaseWatcher.TargetData 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.TargetData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.TargetData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.TargetData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class WatcherCollection : Azure.ResourceManager.ArmCollection, System.Collections.Generic.IAsyncEnumerable, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + protected WatcherCollection() { } + public virtual Azure.ResourceManager.ArmOperation CreateOrUpdate(Azure.WaitUntil waitUntil, string watcherName, Azure.ResourceManager.DatabaseWatcher.WatcherData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(Azure.WaitUntil waitUntil, string watcherName, Azure.ResourceManager.DatabaseWatcher.WatcherData data, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Exists(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> ExistsAsync(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Pageable GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.NullableResponse GetIfExists(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetIfExistsAsync(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + System.Collections.Generic.IAsyncEnumerator System.Collections.Generic.IAsyncEnumerable.GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken) { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public partial class WatcherData : Azure.ResourceManager.Models.TrackedResourceData, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public WatcherData(Azure.Core.AzureLocation location) { } + public Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityV4 Identity { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.WatcherProperties Properties { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.WatcherData 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.WatcherData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class WatcherResource : Azure.ResourceManager.ArmResource, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public static readonly Azure.Core.ResourceType ResourceType; + protected WatcherResource() { } + public virtual Azure.ResourceManager.DatabaseWatcher.WatcherData Data { get { throw null; } } + public virtual bool HasData { get { throw null; } } + public virtual Azure.Response AddTag(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> AddTagAsync(string key, string value, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static Azure.Core.ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string watcherName) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Delete(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Get(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetAlertRuleResource(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetAlertRuleResourceAsync(string alertRuleResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceCollection GetAlertRuleResources() { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response GetHealthValidation(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetHealthValidationAsync(string healthValidationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.HealthValidationCollection GetHealthValidations() { throw null; } + public virtual Azure.Response GetSharedPrivateLinkResource(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetSharedPrivateLinkResourceAsync(string sharedPrivateLinkResourceName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceCollection GetSharedPrivateLinkResources() { throw null; } + public virtual Azure.Response GetTarget(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetTargetAsync(string targetName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.TargetCollection GetTargets() { throw null; } + public virtual Azure.Response RemoveTag(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> RemoveTagAsync(string key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response SetTags(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SetTagsAsync(System.Collections.Generic.IDictionary tags, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Start(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task StartAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Stop(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task StopAsync(Azure.WaitUntil waitUntil, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + Azure.ResourceManager.DatabaseWatcher.WatcherData 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.WatcherData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public virtual Azure.ResourceManager.ArmOperation Update(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.Models.WatcherPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateAsync(Azure.WaitUntil waitUntil, Azure.ResourceManager.DatabaseWatcher.Models.WatcherPatch patch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } +} +namespace Azure.ResourceManager.DatabaseWatcher.Mocking +{ + public partial class MockableDatabaseWatcherArmClient : Azure.ResourceManager.ArmResource + { + protected MockableDatabaseWatcherArmClient() { } + public virtual Azure.ResourceManager.DatabaseWatcher.AlertRuleResource GetAlertRuleResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.HealthValidationResource GetHealthValidationResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResource GetSharedPrivateLinkResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.TargetResource GetTargetResource(Azure.Core.ResourceIdentifier id) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.WatcherResource GetWatcherResource(Azure.Core.ResourceIdentifier id) { throw null; } + } + public partial class MockableDatabaseWatcherResourceGroupResource : Azure.ResourceManager.ArmResource + { + protected MockableDatabaseWatcherResourceGroupResource() { } + public virtual Azure.Response GetWatcher(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetWatcherAsync(string watcherName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.ResourceManager.DatabaseWatcher.WatcherCollection GetWatchers() { throw null; } + } + public partial class MockableDatabaseWatcherSubscriptionResource : Azure.ResourceManager.ArmResource + { + protected MockableDatabaseWatcherSubscriptionResource() { } + public virtual Azure.Pageable GetWatchers(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetWatchersAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } +} +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AlertRuleCreationProperty : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AlertRuleCreationProperty(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty CreatedWithActionGroup { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty None { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + 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 bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty left, Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty right) { throw null; } + public override string ToString() { throw null; } + } + public partial class AlertRuleResourceProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AlertRuleResourceProperties(Azure.Core.ResourceIdentifier alertRuleResourceId, Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty createdWithProperties, System.DateTimeOffset createdOn, string alertRuleTemplateId, string alertRuleTemplateVersion) { } + public Azure.Core.ResourceIdentifier AlertRuleResourceId { get { throw null; } set { } } + public string AlertRuleTemplateId { get { throw null; } set { } } + public string AlertRuleTemplateVersion { get { throw null; } set { } } + public System.DateTimeOffset CreatedOn { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty CreatedWithProperties { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? ProvisioningState { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleResourceProperties 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.AlertRuleResourceProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public static partial class ArmDatabaseWatcherModelFactory + { + public static Azure.ResourceManager.DatabaseWatcher.AlertRuleResourceData AlertRuleResourceData(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.AlertRuleResourceProperties properties = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleResourceProperties AlertRuleResourceProperties(Azure.Core.ResourceIdentifier alertRuleResourceId = null, Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty createdWithProperties = default(Azure.ResourceManager.DatabaseWatcher.Models.AlertRuleCreationProperty), System.DateTimeOffset createdOn = default(System.DateTimeOffset), Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState?), string alertRuleTemplateId = null, string alertRuleTemplateVersion = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.HealthValidationData HealthValidationData(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.HealthValidationProperties properties = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.HealthValidationProperties HealthValidationProperties(System.DateTimeOffset startOn = default(System.DateTimeOffset), System.DateTimeOffset endOn = default(System.DateTimeOffset), Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus status = default(Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus), System.Collections.Generic.IEnumerable issues = null, Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState?)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityV4 ManagedServiceIdentityV4(System.Guid? principalId = default(System.Guid?), System.Guid? tenantId = default(System.Guid?), Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType type = default(Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType), System.Collections.Generic.IDictionary userAssignedIdentities = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.SharedPrivateLinkResourceData SharedPrivateLinkResourceData(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.SharedPrivateLinkResourceProperties properties = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceProperties SharedPrivateLinkResourceProperties(Azure.Core.ResourceIdentifier privateLinkResourceId = null, string groupId = null, string requestMessage = null, string dnsZone = null, Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus? status = default(Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus?), Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState?)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.SqlDbElasticPoolTargetProperties SqlDbElasticPoolTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType = default(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType), Azure.ResourceManager.DatabaseWatcher.Models.VaultSecret targetVault = null, string connectionServerName = null, Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState?), Azure.Core.ResourceIdentifier sqlEpResourceId = null, Azure.Core.ResourceIdentifier anchorDatabaseResourceId = null, bool? readIntent = default(bool?)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.SqlDbSingleDatabaseTargetProperties SqlDbSingleDatabaseTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType = default(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType), Azure.ResourceManager.DatabaseWatcher.Models.VaultSecret targetVault = null, string connectionServerName = null, Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState?), Azure.Core.ResourceIdentifier sqlDbResourceId = null, bool? readIntent = default(bool?)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.SqlMiTargetProperties SqlMiTargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType = default(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType), Azure.ResourceManager.DatabaseWatcher.Models.VaultSecret targetVault = null, string connectionServerName = null, Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState?), Azure.Core.ResourceIdentifier sqlMiResourceId = null, int? connectionTcpPort = default(int?), bool? readIntent = default(bool?)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.TargetData TargetData(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.TargetProperties properties = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.TargetProperties TargetProperties(string targetType = null, Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType = default(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType), Azure.ResourceManager.DatabaseWatcher.Models.VaultSecret targetVault = null, string connectionServerName = null, Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState?)) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.ValidationIssue ValidationIssue(string errorCode = null, string errorMessage = null, string additionalDetails = null, string recommendationMessage = null, System.Uri recommendationUri = null, Azure.Core.ResourceIdentifier relatedResourceId = null, string relatedResourceType = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.WatcherData WatcherData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.DatabaseWatcher.Models.WatcherProperties properties = null, Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityV4 identity = null) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.WatcherProperties WatcherProperties(Azure.ResourceManager.DatabaseWatcher.Models.Datastore datastore = null, Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus? status = default(Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus?), Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState? provisioningState = default(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState?), Azure.Core.ResourceIdentifier defaultAlertRuleIdentityResourceId = null) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct DatabaseWatcherProvisioningState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public DatabaseWatcherProvisioningState(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState Canceled { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState Failed { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState Succeeded { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + 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 bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState left, Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState right) { throw null; } + public override string ToString() { throw null; } + } + public partial class Datastore : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public Datastore(string kustoClusterUri, string kustoDataIngestionUri, string kustoDatabaseName, string kustoManagementUri, Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType kustoOfferingType) { } + public Azure.Core.ResourceIdentifier AdxClusterResourceId { get { throw null; } set { } } + public string KustoClusterDisplayName { get { throw null; } set { } } + public string KustoClusterUri { get { throw null; } set { } } + public string KustoDatabaseName { get { throw null; } set { } } + public string KustoDataIngestionUri { get { throw null; } set { } } + public string KustoManagementUri { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType KustoOfferingType { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.Datastore 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.Datastore System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class HealthValidationProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal HealthValidationProperties() { } + public System.DateTimeOffset EndOn { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Issues { get { throw null; } } + public Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? ProvisioningState { get { throw null; } } + public System.DateTimeOffset StartOn { get { throw null; } } + public Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus Status { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.HealthValidationProperties 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.HealthValidationProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct KustoOfferingType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public KustoOfferingType(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType Adx { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType Fabric { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType Free { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + 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 bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType left, Azure.ResourceManager.DatabaseWatcher.Models.KustoOfferingType right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ManagedServiceIdentityType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ManagedServiceIdentityType(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType None { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType SystemAndUserAssigned { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType SystemAssigned { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType UserAssigned { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType left, Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType right) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType left, Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class ManagedServiceIdentityV4 : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ManagedServiceIdentityV4(Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType type) { } + public System.Guid? PrincipalId { get { throw null; } } + public System.Guid? TenantId { get { throw null; } } + public Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityType Type { get { throw null; } set { } } + public System.Collections.Generic.IDictionary UserAssignedIdentities { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityV4 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.ManagedServiceIdentityV4 System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ResourceProvisioningState : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ResourceProvisioningState(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState Canceled { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState Failed { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState Succeeded { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState left, Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState right) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState left, Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState right) { throw null; } + public override string ToString() { throw null; } + } + public partial class SharedPrivateLinkResourceProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SharedPrivateLinkResourceProperties(Azure.Core.ResourceIdentifier privateLinkResourceId, string groupId, string requestMessage) { } + public string DnsZone { get { throw null; } set { } } + public string GroupId { get { throw null; } set { } } + public Azure.Core.ResourceIdentifier PrivateLinkResourceId { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? ProvisioningState { get { throw null; } } + public string RequestMessage { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus? Status { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceProperties 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.SharedPrivateLinkResourceProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct SharedPrivateLinkResourceStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public SharedPrivateLinkResourceStatus(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus Approved { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus Disconnected { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus Pending { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus Rejected { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus left, Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus right) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus left, Azure.ResourceManager.DatabaseWatcher.Models.SharedPrivateLinkResourceStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class SqlDbElasticPoolTargetProperties : Azure.ResourceManager.DatabaseWatcher.Models.TargetProperties, 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 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 void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + 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; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class SqlDbSingleDatabaseTargetProperties : Azure.ResourceManager.DatabaseWatcher.Models.TargetProperties, 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 bool? ReadIntent { get { throw null; } set { } } + public Azure.Core.ResourceIdentifier SqlDbResourceId { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + 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; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class SqlMiTargetProperties : Azure.ResourceManager.DatabaseWatcher.Models.TargetProperties, 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 int? ConnectionTcpPort { get { throw null; } set { } } + public bool? ReadIntent { get { throw null; } set { } } + public Azure.Core.ResourceIdentifier SqlMiResourceId { get { throw null; } set { } } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + 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; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct TargetAuthenticationType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public TargetAuthenticationType(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType Aad { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType Sql { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + 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 bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType left, Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType right) { throw null; } + public override string ToString() { throw null; } + } + public abstract partial class TargetProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + protected TargetProperties(Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType targetAuthenticationType, string connectionServerName) { } + public string ConnectionServerName { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.ResourceProvisioningState? ProvisioningState { get { throw null; } } + public Azure.ResourceManager.DatabaseWatcher.Models.TargetAuthenticationType TargetAuthenticationType { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.VaultSecret TargetVault { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.TargetProperties 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.TargetProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ValidationIssue : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ValidationIssue() { } + public string AdditionalDetails { get { throw null; } } + public string ErrorCode { get { throw null; } } + public string ErrorMessage { get { throw null; } } + public string RecommendationMessage { get { throw null; } } + public System.Uri RecommendationUri { get { throw null; } } + public Azure.Core.ResourceIdentifier RelatedResourceId { get { throw null; } } + public string RelatedResourceType { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.ValidationIssue 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.ValidationIssue System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ValidationStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ValidationStatus(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus Canceled { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus Failed { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus NotStarted { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus Running { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus Succeeded { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus TimedOut { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus left, Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus right) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus left, Azure.ResourceManager.DatabaseWatcher.Models.ValidationStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class VaultSecret : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public VaultSecret() { } + 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 void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.VaultSecret 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.VaultSecret System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class WatcherPatch : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public WatcherPatch() { } + public Azure.ResourceManager.DatabaseWatcher.Models.ManagedServiceIdentityV4 Identity { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.WatcherUpdateProperties Properties { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.WatcherPatch 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.WatcherPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class WatcherProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public WatcherProperties() { } + public Azure.ResourceManager.DatabaseWatcher.Models.Datastore Datastore { get { throw null; } set { } } + public Azure.Core.ResourceIdentifier DefaultAlertRuleIdentityResourceId { get { throw null; } set { } } + public Azure.ResourceManager.DatabaseWatcher.Models.DatabaseWatcherProvisioningState? ProvisioningState { get { throw null; } } + public Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus? Status { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.WatcherProperties 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.WatcherProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct WatcherStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public WatcherStatus(string value) { throw null; } + public static Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus Deleting { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus Running { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus Starting { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus Stopped { get { throw null; } } + public static Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus Stopping { get { throw null; } } + public bool Equals(Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus left, Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus right) { throw null; } + public static implicit operator Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus (string value) { throw null; } + public static bool operator !=(Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus left, Azure.ResourceManager.DatabaseWatcher.Models.WatcherStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class WatcherUpdateProperties : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public WatcherUpdateProperties() { } + public Azure.ResourceManager.DatabaseWatcher.Models.Datastore Datastore { get { throw null; } set { } } + public Azure.Core.ResourceIdentifier DefaultAlertRuleIdentityResourceId { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.ResourceManager.DatabaseWatcher.Models.WatcherUpdateProperties 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.WatcherUpdateProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/assets.json b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/assets.json new file mode 100644 index 000000000000..169779905282 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/assets.json @@ -0,0 +1,7 @@ + +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "net", + "TagPrefix": "net/databasewatcher/Azure.ResourceManager.DatabaseWatcher", + "Tag": "" +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Azure.ResourceManager.DatabaseWatcher.Samples.csproj b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Azure.ResourceManager.DatabaseWatcher.Samples.csproj new file mode 100644 index 000000000000..4750448f1e63 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Azure.ResourceManager.DatabaseWatcher.Samples.csproj @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_AlertRuleResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_AlertRuleResource.cs new file mode 100644 index 000000000000..3485ac40f5df --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_AlertRuleResource.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.DatabaseWatcher.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.DatabaseWatcher.Samples +{ + public partial class Sample_AlertRuleResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_AlertRuleResourcesGetMaximumSet() + { + // Generated from example definition: 2025-01-02/AlertRuleResources_Get_MaximumSet_Gen.json + // this example is just showing the usage of "AlertRuleResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AlertRuleResource created on azure + // for more information of creating AlertRuleResource, please refer to the document of AlertRuleResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + string alertRuleResourceName = "testAlert"; + ResourceIdentifier alertRuleResourceId = AlertRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName, alertRuleResourceName); + AlertRuleResource alertRuleResource = client.GetAlertRuleResource(alertRuleResourceId); + + // invoke the operation + AlertRuleResource result = await alertRuleResource.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AlertRuleResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_AlertRuleResourcesDeleteMaximumSet() + { + // Generated from example definition: 2025-01-02/AlertRuleResources_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "AlertRuleResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AlertRuleResource created on azure + // for more information of creating AlertRuleResource, please refer to the document of AlertRuleResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + string alertRuleResourceName = "testAlert"; + ResourceIdentifier alertRuleResourceId = AlertRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName, alertRuleResourceName); + AlertRuleResource alertRuleResource = client.GetAlertRuleResource(alertRuleResourceId); + + // invoke the operation + await alertRuleResource.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_AlertRuleResourcesCreateOrUpdateMaximumSet() + { + // Generated from example definition: 2025-01-02/AlertRuleResources_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "AlertRuleResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AlertRuleResource created on azure + // for more information of creating AlertRuleResource, please refer to the document of AlertRuleResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + string alertRuleResourceName = "testAlert"; + ResourceIdentifier alertRuleResourceId = AlertRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName, alertRuleResourceName); + AlertRuleResource alertRuleResource = client.GetAlertRuleResource(alertRuleResourceId); + + // invoke the operation + AlertRuleResourceData data = new AlertRuleResourceData + { + Properties = new AlertRuleResourceProperties(new ResourceIdentifier("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878Be/resourceGroups/rgWatcher/providers/microsoft.insights/scheduledqueryrules/alerts-demo"), AlertRuleCreationProperty.CreatedWithActionGroup, DateTimeOffset.Parse("2024-07-25T15:38:47.798Z"), "someTemplateId", "1.0"), + }; + ArmOperation lro = await alertRuleResource.UpdateAsync(WaitUntil.Completed, data); + AlertRuleResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AlertRuleResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_AlertRuleResourceCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_AlertRuleResourceCollection.cs new file mode 100644 index 000000000000..44c4f3db380a --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_AlertRuleResourceCollection.cs @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.DatabaseWatcher.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.DatabaseWatcher.Samples +{ + public partial class Sample_AlertRuleResourceCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_AlertRuleResourcesCreateOrUpdateMaximumSet() + { + // Generated from example definition: 2025-01-02/AlertRuleResources_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "AlertRuleResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this AlertRuleResource + AlertRuleResourceCollection collection = watcher.GetAlertRuleResources(); + + // invoke the operation + string alertRuleResourceName = "testAlert"; + AlertRuleResourceData data = new AlertRuleResourceData + { + Properties = new AlertRuleResourceProperties(new ResourceIdentifier("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878Be/resourceGroups/rgWatcher/providers/microsoft.insights/scheduledqueryrules/alerts-demo"), AlertRuleCreationProperty.CreatedWithActionGroup, DateTimeOffset.Parse("2024-07-25T15:38:47.798Z"), "someTemplateId", "1.0"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, alertRuleResourceName, data); + AlertRuleResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AlertRuleResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_AlertRuleResourcesGetMaximumSet() + { + // Generated from example definition: 2025-01-02/AlertRuleResources_Get_MaximumSet_Gen.json + // this example is just showing the usage of "AlertRuleResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this AlertRuleResource + AlertRuleResourceCollection collection = watcher.GetAlertRuleResources(); + + // invoke the operation + string alertRuleResourceName = "testAlert"; + AlertRuleResource result = await collection.GetAsync(alertRuleResourceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AlertRuleResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_AlertRuleResourcesListByParentMaximumSet() + { + // Generated from example definition: 2025-01-02/AlertRuleResources_ListByParent_MaximumSet_Gen.json + // this example is just showing the usage of "AlertRuleResource_ListByParent" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this AlertRuleResource + AlertRuleResourceCollection collection = watcher.GetAlertRuleResources(); + + // invoke the operation and iterate over the result + await foreach (AlertRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AlertRuleResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_AlertRuleResourcesGetMaximumSet() + { + // Generated from example definition: 2025-01-02/AlertRuleResources_Get_MaximumSet_Gen.json + // this example is just showing the usage of "AlertRuleResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this AlertRuleResource + AlertRuleResourceCollection collection = watcher.GetAlertRuleResources(); + + // invoke the operation + string alertRuleResourceName = "testAlert"; + bool result = await collection.ExistsAsync(alertRuleResourceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_AlertRuleResourcesGetMaximumSet() + { + // Generated from example definition: 2025-01-02/AlertRuleResources_Get_MaximumSet_Gen.json + // this example is just showing the usage of "AlertRuleResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this AlertRuleResource + AlertRuleResourceCollection collection = watcher.GetAlertRuleResources(); + + // invoke the operation + string alertRuleResourceName = "testAlert"; + NullableResponse response = await collection.GetIfExistsAsync(alertRuleResourceName); + AlertRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AlertRuleResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_HealthValidationCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_HealthValidationCollection.cs new file mode 100644 index 000000000000..d42c055011fa --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_HealthValidationCollection.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.ResourceManager.DatabaseWatcher.Samples +{ + public partial class Sample_HealthValidationCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_HealthValidationsGetMaximumSet() + { + // Generated from example definition: 2025-01-02/HealthValidations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "HealthValidation_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this HealthValidationResource + HealthValidationCollection collection = watcher.GetHealthValidations(); + + // invoke the operation + string healthValidationName = "testHealthValidation"; + HealthValidationResource result = await collection.GetAsync(healthValidationName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthValidationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_HealthValidationsListByParentMaximumSet() + { + // Generated from example definition: 2025-01-02/HealthValidations_ListByParent_MaximumSet_Gen.json + // this example is just showing the usage of "HealthValidation_ListByParent" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this HealthValidationResource + HealthValidationCollection collection = watcher.GetHealthValidations(); + + // invoke the operation and iterate over the result + await foreach (HealthValidationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthValidationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_HealthValidationsGetMaximumSet() + { + // Generated from example definition: 2025-01-02/HealthValidations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "HealthValidation_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this HealthValidationResource + HealthValidationCollection collection = watcher.GetHealthValidations(); + + // invoke the operation + string healthValidationName = "testHealthValidation"; + bool result = await collection.ExistsAsync(healthValidationName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_HealthValidationsGetMaximumSet() + { + // Generated from example definition: 2025-01-02/HealthValidations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "HealthValidation_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this HealthValidationResource + HealthValidationCollection collection = watcher.GetHealthValidations(); + + // invoke the operation + string healthValidationName = "testHealthValidation"; + NullableResponse response = await collection.GetIfExistsAsync(healthValidationName); + HealthValidationResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthValidationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_HealthValidationResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_HealthValidationResource.cs new file mode 100644 index 000000000000..ce9b4741820d --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_HealthValidationResource.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.ResourceManager.DatabaseWatcher.Samples +{ + public partial class Sample_HealthValidationResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_HealthValidationsGetMaximumSet() + { + // Generated from example definition: 2025-01-02/HealthValidations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "HealthValidation_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HealthValidationResource created on azure + // for more information of creating HealthValidationResource, please refer to the document of HealthValidationResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + string healthValidationName = "testHealthValidation"; + ResourceIdentifier healthValidationResourceId = HealthValidationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName, healthValidationName); + HealthValidationResource healthValidation = client.GetHealthValidationResource(healthValidationResourceId); + + // invoke the operation + HealthValidationResource result = await healthValidation.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthValidationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task StartValidation_HealthValidationsStartValidationMaximumSet() + { + // Generated from example definition: 2025-01-02/HealthValidations_StartValidation_MaximumSet_Gen.json + // this example is just showing the usage of "HealthValidations_StartValidation" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HealthValidationResource created on azure + // for more information of creating HealthValidationResource, please refer to the document of HealthValidationResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + string healthValidationName = "testHealthValidation"; + ResourceIdentifier healthValidationResourceId = HealthValidationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName, healthValidationName); + HealthValidationResource healthValidation = client.GetHealthValidationResource(healthValidationResourceId); + + // invoke the operation + ArmOperation lro = await healthValidation.StartValidationAsync(WaitUntil.Completed); + HealthValidationResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthValidationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_SharedPrivateLinkResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_SharedPrivateLinkResource.cs new file mode 100644 index 000000000000..8e163d7bf921 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_SharedPrivateLinkResource.cs @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.DatabaseWatcher.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.DatabaseWatcher.Samples +{ + public partial class Sample_SharedPrivateLinkResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_SharedPrivateLinkResourcesGetMaximumSet() + { + // Generated from example definition: 2025-01-02/SharedPrivateLinkResources_Get_MaximumSet_Gen.json + // this example is just showing the usage of "SharedPrivateLinkResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SharedPrivateLinkResource created on azure + // for more information of creating SharedPrivateLinkResource, please refer to the document of SharedPrivateLinkResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + string sharedPrivateLinkResourceName = "monitoringh22eed"; + ResourceIdentifier sharedPrivateLinkResourceId = SharedPrivateLinkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName, sharedPrivateLinkResourceName); + SharedPrivateLinkResource sharedPrivateLinkResource = client.GetSharedPrivateLinkResource(sharedPrivateLinkResourceId); + + // invoke the operation + SharedPrivateLinkResource result = await sharedPrivateLinkResource.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SharedPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_SharedPrivateLinkResourcesDeleteMaximumSet() + { + // Generated from example definition: 2025-01-02/SharedPrivateLinkResources_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "SharedPrivateLinkResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SharedPrivateLinkResource created on azure + // for more information of creating SharedPrivateLinkResource, please refer to the document of SharedPrivateLinkResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + string sharedPrivateLinkResourceName = "monitoringh22eed"; + ResourceIdentifier sharedPrivateLinkResourceId = SharedPrivateLinkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName, sharedPrivateLinkResourceName); + SharedPrivateLinkResource sharedPrivateLinkResource = client.GetSharedPrivateLinkResource(sharedPrivateLinkResourceId); + + // invoke the operation + await sharedPrivateLinkResource.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_SharedPrivateLinkResourcesCreateMaximumSet() + { + // Generated from example definition: 2025-01-02/SharedPrivateLinkResources_Create_MaximumSet_Gen.json + // this example is just showing the usage of "SharedPrivateLinkResource_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SharedPrivateLinkResource created on azure + // for more information of creating SharedPrivateLinkResource, please refer to the document of SharedPrivateLinkResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + string sharedPrivateLinkResourceName = "monitoringh22eed"; + ResourceIdentifier sharedPrivateLinkResourceId = SharedPrivateLinkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName, sharedPrivateLinkResourceName); + SharedPrivateLinkResource sharedPrivateLinkResource = client.GetSharedPrivateLinkResource(sharedPrivateLinkResourceId); + + // invoke the operation + SharedPrivateLinkResourceData data = new SharedPrivateLinkResourceData + { + Properties = new SharedPrivateLinkResourceProperties(new ResourceIdentifier("/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest-ddat4p/providers/Microsoft.KeyVault/vaults/kvmo3ej9ih"), "vault", "request message") + { + DnsZone = "ec3ae9d410ba", + }, + }; + ArmOperation lro = await sharedPrivateLinkResource.UpdateAsync(WaitUntil.Completed, data); + SharedPrivateLinkResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SharedPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_SharedPrivateLinkResourceCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_SharedPrivateLinkResourceCollection.cs new file mode 100644 index 000000000000..8ea926df43bc --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_SharedPrivateLinkResourceCollection.cs @@ -0,0 +1,203 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.DatabaseWatcher.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.DatabaseWatcher.Samples +{ + public partial class Sample_SharedPrivateLinkResourceCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_SharedPrivateLinkResourcesCreateMaximumSet() + { + // Generated from example definition: 2025-01-02/SharedPrivateLinkResources_Create_MaximumSet_Gen.json + // this example is just showing the usage of "SharedPrivateLinkResource_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this SharedPrivateLinkResource + SharedPrivateLinkResourceCollection collection = watcher.GetSharedPrivateLinkResources(); + + // invoke the operation + string sharedPrivateLinkResourceName = "monitoringh22eed"; + SharedPrivateLinkResourceData data = new SharedPrivateLinkResourceData + { + Properties = new SharedPrivateLinkResourceProperties(new ResourceIdentifier("/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest-ddat4p/providers/Microsoft.KeyVault/vaults/kvmo3ej9ih"), "vault", "request message") + { + DnsZone = "ec3ae9d410ba", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sharedPrivateLinkResourceName, data); + SharedPrivateLinkResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SharedPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_SharedPrivateLinkResourcesGetMaximumSet() + { + // Generated from example definition: 2025-01-02/SharedPrivateLinkResources_Get_MaximumSet_Gen.json + // this example is just showing the usage of "SharedPrivateLinkResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this SharedPrivateLinkResource + SharedPrivateLinkResourceCollection collection = watcher.GetSharedPrivateLinkResources(); + + // invoke the operation + string sharedPrivateLinkResourceName = "monitoringh22eed"; + SharedPrivateLinkResource result = await collection.GetAsync(sharedPrivateLinkResourceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SharedPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_SharedPrivateLinkResourcesListByWatcherMaximumSet() + { + // Generated from example definition: 2025-01-02/SharedPrivateLinkResources_ListByWatcher_MaximumSet_Gen.json + // this example is just showing the usage of "SharedPrivateLinkResource_ListByWatcher" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this SharedPrivateLinkResource + SharedPrivateLinkResourceCollection collection = watcher.GetSharedPrivateLinkResources(); + + // invoke the operation and iterate over the result + await foreach (SharedPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SharedPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_SharedPrivateLinkResourcesGetMaximumSet() + { + // Generated from example definition: 2025-01-02/SharedPrivateLinkResources_Get_MaximumSet_Gen.json + // this example is just showing the usage of "SharedPrivateLinkResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this SharedPrivateLinkResource + SharedPrivateLinkResourceCollection collection = watcher.GetSharedPrivateLinkResources(); + + // invoke the operation + string sharedPrivateLinkResourceName = "monitoringh22eed"; + bool result = await collection.ExistsAsync(sharedPrivateLinkResourceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_SharedPrivateLinkResourcesGetMaximumSet() + { + // Generated from example definition: 2025-01-02/SharedPrivateLinkResources_Get_MaximumSet_Gen.json + // this example is just showing the usage of "SharedPrivateLinkResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this SharedPrivateLinkResource + SharedPrivateLinkResourceCollection collection = watcher.GetSharedPrivateLinkResources(); + + // invoke the operation + string sharedPrivateLinkResourceName = "monitoringh22eed"; + NullableResponse response = await collection.GetIfExistsAsync(sharedPrivateLinkResourceName); + SharedPrivateLinkResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SharedPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 000000000000..52b5589c03f6 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.DatabaseWatcher.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetWatchers_WatchersListBySubscriptionMaximumSet() + { + // Generated from example definition: 2025-01-02/Watchers_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "Watcher_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (WatcherResource item in subscriptionResource.GetWatchersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WatcherData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_TargetCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_TargetCollection.cs new file mode 100644 index 000000000000..7a680ae22dbe --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_TargetCollection.cs @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.DatabaseWatcher.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.DatabaseWatcher.Samples +{ + public partial class Sample_TargetCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_TargetsCreateOrUpdateMaximumSet() + { + // Generated from example definition: 2025-01-02/Targets_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "Target_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this TargetResource + TargetCollection collection = watcher.GetTargets(); + + // invoke the operation + string targetName = "monitoringh22eed"; + TargetData data = new TargetData + { + Properties = new SqlDbSingleDatabaseTargetProperties(TargetAuthenticationType.Aad, "sqlServero1ihe2", new ResourceIdentifier("/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest-ddat4p/providers/Microsoft.Sql/servers/m1/databases/m2")), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, targetName, data); + TargetResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TargetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_TargetsGetMaximumSet() + { + // Generated from example definition: 2025-01-02/Targets_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Target_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this TargetResource + TargetCollection collection = watcher.GetTargets(); + + // invoke the operation + string targetName = "monitoringh22eed"; + TargetResource result = await collection.GetAsync(targetName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TargetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_TargetsListByWatcherMaximumSet() + { + // Generated from example definition: 2025-01-02/Targets_ListByWatcher_MaximumSet_Gen.json + // this example is just showing the usage of "Target_ListByWatcher" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this TargetResource + TargetCollection collection = watcher.GetTargets(); + + // invoke the operation and iterate over the result + await foreach (TargetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TargetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_TargetsGetMaximumSet() + { + // Generated from example definition: 2025-01-02/Targets_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Target_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this TargetResource + TargetCollection collection = watcher.GetTargets(); + + // invoke the operation + string targetName = "monitoringh22eed"; + bool result = await collection.ExistsAsync(targetName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_TargetsGetMaximumSet() + { + // Generated from example definition: 2025-01-02/Targets_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Target_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // get the collection of this TargetResource + TargetCollection collection = watcher.GetTargets(); + + // invoke the operation + string targetName = "monitoringh22eed"; + NullableResponse response = await collection.GetIfExistsAsync(targetName); + TargetResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TargetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_TargetResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_TargetResource.cs new file mode 100644 index 000000000000..6c10469af52d --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_TargetResource.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.DatabaseWatcher.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.DatabaseWatcher.Samples +{ + public partial class Sample_TargetResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_TargetsGetMaximumSet() + { + // Generated from example definition: 2025-01-02/Targets_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Target_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this TargetResource created on azure + // for more information of creating TargetResource, please refer to the document of TargetResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + string targetName = "monitoringh22eed"; + ResourceIdentifier targetResourceId = TargetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName, targetName); + TargetResource target = client.GetTargetResource(targetResourceId); + + // invoke the operation + TargetResource result = await target.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TargetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_TargetsDeleteMaximumSet() + { + // Generated from example definition: 2025-01-02/Targets_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "Target_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this TargetResource created on azure + // for more information of creating TargetResource, please refer to the document of TargetResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + string targetName = "monitoringh22eed"; + ResourceIdentifier targetResourceId = TargetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName, targetName); + TargetResource target = client.GetTargetResource(targetResourceId); + + // invoke the operation + await target.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_TargetsCreateOrUpdateMaximumSet() + { + // Generated from example definition: 2025-01-02/Targets_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "Target_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this TargetResource created on azure + // for more information of creating TargetResource, please refer to the document of TargetResource + string subscriptionId = "49e0fbd3-75e8-44e7-96fd-5b64d9ad818d"; + string resourceGroupName = "apiTest-ddat4p"; + string watcherName = "databasemo3ej9ih"; + string targetName = "monitoringh22eed"; + ResourceIdentifier targetResourceId = TargetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName, targetName); + TargetResource target = client.GetTargetResource(targetResourceId); + + // invoke the operation + TargetData data = new TargetData + { + Properties = new SqlDbSingleDatabaseTargetProperties(TargetAuthenticationType.Aad, "sqlServero1ihe2", new ResourceIdentifier("/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest-ddat4p/providers/Microsoft.Sql/servers/m1/databases/m2")), + }; + ArmOperation lro = await target.UpdateAsync(WaitUntil.Completed, data); + TargetResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TargetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_WatcherCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_WatcherCollection.cs new file mode 100644 index 000000000000..840349b9b52c --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_WatcherCollection.cs @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.DatabaseWatcher.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.DatabaseWatcher.Samples +{ + public partial class Sample_WatcherCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_WatchersCreateOrUpdateMaximumSet() + { + // Generated from example definition: 2025-01-02/Watchers_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "Watcher_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this WatcherResource + WatcherCollection collection = resourceGroupResource.GetWatchers(); + + // invoke the operation + string watcherName = "testWatcher"; + WatcherData data = new WatcherData(new AzureLocation("eastus2")) + { + Properties = new WatcherProperties + { + Datastore = new Datastore("https://kustouri-adx.eastus.kusto.windows.net", "https://ingest-kustouri-adx.eastus.kusto.windows.net", "kustoDatabaseName1", "https://portal.azure.com/", KustoOfferingType.Adx) + { + AdxClusterResourceId = new ResourceIdentifier("/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + KustoClusterDisplayName = "kustoUri-adx", + }, + DefaultAlertRuleIdentityResourceId = new ResourceIdentifier("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/3pmtest"), + }, + Identity = new ManagedServiceIdentityV4(ManagedServiceIdentityType.SystemAssigned), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, watcherName, data); + WatcherResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WatcherData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_WatchersGetMaximumSet() + { + // Generated from example definition: 2025-01-02/Watchers_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Watcher_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this WatcherResource + WatcherCollection collection = resourceGroupResource.GetWatchers(); + + // invoke the operation + string watcherName = "myWatcher"; + WatcherResource result = await collection.GetAsync(watcherName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WatcherData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_WatchersListByResourceGroupMaximumSet() + { + // Generated from example definition: 2025-01-02/Watchers_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "Watcher_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this WatcherResource + WatcherCollection collection = resourceGroupResource.GetWatchers(); + + // invoke the operation and iterate over the result + await foreach (WatcherResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WatcherData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_WatchersGetMaximumSet() + { + // Generated from example definition: 2025-01-02/Watchers_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Watcher_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this WatcherResource + WatcherCollection collection = resourceGroupResource.GetWatchers(); + + // invoke the operation + string watcherName = "myWatcher"; + bool result = await collection.ExistsAsync(watcherName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_WatchersGetMaximumSet() + { + // Generated from example definition: 2025-01-02/Watchers_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Watcher_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this WatcherResource + WatcherCollection collection = resourceGroupResource.GetWatchers(); + + // invoke the operation + string watcherName = "myWatcher"; + NullableResponse response = await collection.GetIfExistsAsync(watcherName); + WatcherResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WatcherData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_WatcherResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_WatcherResource.cs new file mode 100644 index 000000000000..db6444b0f51d --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/samples/Generated/Samples/Sample_WatcherResource.cs @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.DatabaseWatcher.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.DatabaseWatcher.Samples +{ + public partial class Sample_WatcherResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_WatchersGetMaximumSet() + { + // Generated from example definition: 2025-01-02/Watchers_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Watcher_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "myWatcher"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // invoke the operation + WatcherResource result = await watcher.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WatcherData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_WatchersDeleteMaximumSet() + { + // Generated from example definition: 2025-01-02/Watchers_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "Watcher_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // invoke the operation + await watcher.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_WatchersUpdateMaximumSet() + { + // Generated from example definition: 2025-01-02/Watchers_Update_MaximumSet_Gen.json + // this example is just showing the usage of "Watcher_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // invoke the operation + WatcherPatch patch = new WatcherPatch + { + Identity = new ManagedServiceIdentityV4(ManagedServiceIdentityType.SystemAssigned), + Tags = { }, + Properties = new WatcherUpdateProperties + { + Datastore = new Datastore("https://kustouri-adx.eastus.kusto.windows.net", "https://ingest-kustouri-adx.eastus.kusto.windows.net", "kustoDatabaseName1", "https://portal.azure.com/", KustoOfferingType.Adx) + { + AdxClusterResourceId = new ResourceIdentifier("/subscriptions/49e0fbd3-75e8-44e7-96fd-5b64d9ad818d/resourceGroups/apiTest/providers/Microsoft.Kusto/clusters/apiTestKusto"), + KustoClusterDisplayName = "kustoUri-adx", + }, + DefaultAlertRuleIdentityResourceId = new ResourceIdentifier("/subscriptions/469DD77C-C8DB-47B7-B9E1-72D29F8C878B/resourceGroups/rgWatcher/providers/Microsoft.ManagedIdentity/userAssignedIdentities/newtest"), + }, + }; + ArmOperation lro = await watcher.UpdateAsync(WaitUntil.Completed, patch); + WatcherResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WatcherData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Start_WatchersStartMaximumSet() + { + // Generated from example definition: 2025-01-02/Watchers_Start_MaximumSet_Gen.json + // this example is just showing the usage of "Watchers_Start" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "testWatcher"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // invoke the operation + await watcher.StartAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Stop_WatchersStopMaximumSet() + { + // Generated from example definition: 2025-01-02/Watchers_Stop_MaximumSet_Gen.json + // this example is just showing the usage of "Watchers_Stop" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this WatcherResource created on azure + // for more information of creating WatcherResource, please refer to the document of WatcherResource + string subscriptionId = "A76F9850-996B-40B3-94D4-C98110A0EEC9"; + string resourceGroupName = "rgWatcher"; + string watcherName = "myWatcher"; + ResourceIdentifier watcherResourceId = WatcherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, watcherName); + WatcherResource watcher = client.GetWatcherResource(watcherResourceId); + + // invoke the operation + await watcher.StopAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Azure.ResourceManager.DatabaseWatcher.csproj b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Azure.ResourceManager.DatabaseWatcher.csproj new file mode 100644 index 000000000000..80105c7a5309 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Azure.ResourceManager.DatabaseWatcher.csproj @@ -0,0 +1,8 @@ + + + Azure Resource Manager client SDK for Azure resource provider DatabaseWatcher. + 1.0.0-beta.1 + azure;management;arm;resource manager;databasewatcher + Azure.ResourceManager.DatabaseWatcher + + diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResource.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResource.Serialization.cs new file mode 100644 index 000000000000..f6ae198f9d4c --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + public partial class AlertRuleResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + AlertRuleResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + AlertRuleResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResource.cs new file mode 100644 index 000000000000..fd418580c368 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResource.cs @@ -0,0 +1,355 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A Class representing an AlertRuleResource along with the instance operations that can be performed on it. + /// If you have a you can construct an + /// from an instance of using the GetAlertRuleResource method. + /// Otherwise you can get one from its parent resource using the GetAlertRuleResource method. + /// + public partial class AlertRuleResource : 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 _alertRuleResourceClientDiagnostics; + private readonly AlertRuleResourcesRestOperations _alertRuleResourceRestClient; + private readonly AlertRuleResourceData _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. + protected AlertRuleResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal AlertRuleResource(ArmClient client, AlertRuleResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal AlertRuleResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _alertRuleResourceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string alertRuleResourceApiVersion); + _alertRuleResourceRestClient = new AlertRuleResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, alertRuleResourceApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 AlertRuleResourceData 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)); + } + + /// + /// 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 cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _alertRuleResourceClientDiagnostics.CreateScope("AlertRuleResource.Get"); + scope.Start(); + try + { + var response = await _alertRuleResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new AlertRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _alertRuleResourceClientDiagnostics.CreateScope("AlertRuleResource.Get"); + scope.Start(); + try + { + var response = _alertRuleResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new AlertRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a AlertRuleResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// + /// + /// Operation Id + /// AlertRuleResource_Delete + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _alertRuleResourceClientDiagnostics.CreateScope("AlertRuleResource.Delete"); + scope.Start(); + try + { + var response = await _alertRuleResourceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _alertRuleResourceRestClient.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); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a AlertRuleResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// + /// + /// Operation Id + /// AlertRuleResource_Delete + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _alertRuleResourceClientDiagnostics.CreateScope("AlertRuleResource.Delete"); + scope.Start(); + try + { + var response = _alertRuleResourceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var uri = _alertRuleResourceRestClient.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); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a AlertRuleResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// + /// + /// Operation Id + /// AlertRuleResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, AlertRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _alertRuleResourceClientDiagnostics.CreateScope("AlertRuleResource.Update"); + scope.Start(); + try + { + var response = await _alertRuleResourceRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var uri = _alertRuleResourceRestClient.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 AlertRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a AlertRuleResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// + /// + /// Operation Id + /// AlertRuleResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, AlertRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _alertRuleResourceClientDiagnostics.CreateScope("AlertRuleResource.Update"); + scope.Start(); + try + { + var response = _alertRuleResourceRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var uri = _alertRuleResourceRestClient.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 AlertRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourceCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourceCollection.cs new file mode 100644 index 000000000000..de00e95cf4cb --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourceCollection.cs @@ -0,0 +1,497 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get an instance call the GetAlertRuleResources method from an instance of . + /// + public partial class AlertRuleResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _alertRuleResourceClientDiagnostics; + private readonly AlertRuleResourcesRestOperations _alertRuleResourceRestClient; + + /// Initializes a new instance of the class for mocking. + protected AlertRuleResourceCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal AlertRuleResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _alertRuleResourceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", AlertRuleResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(AlertRuleResource.ResourceType, out string alertRuleResourceApiVersion); + _alertRuleResourceRestClient = new AlertRuleResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, alertRuleResourceApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != WatcherResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, WatcherResource.ResourceType), nameof(id)); + } + + /// + /// Create a AlertRuleResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// + /// + /// Operation Id + /// AlertRuleResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 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. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string alertRuleResourceName, AlertRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _alertRuleResourceClientDiagnostics.CreateScope("AlertRuleResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _alertRuleResourceRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, data, cancellationToken).ConfigureAwait(false); + var uri = _alertRuleResourceRestClient.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 AlertRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a AlertRuleResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources/{alertRuleResourceName} + /// + /// + /// Operation Id + /// AlertRuleResource_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 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. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string alertRuleResourceName, AlertRuleResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _alertRuleResourceClientDiagnostics.CreateScope("AlertRuleResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _alertRuleResourceRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, data, cancellationToken); + var uri = _alertRuleResourceRestClient.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 AlertRuleResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string alertRuleResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); + + using var scope = _alertRuleResourceClientDiagnostics.CreateScope("AlertRuleResourceCollection.Get"); + scope.Start(); + try + { + var response = await _alertRuleResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new AlertRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string alertRuleResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); + + using var scope = _alertRuleResourceClientDiagnostics.CreateScope("AlertRuleResourceCollection.Get"); + scope.Start(); + try + { + var response = _alertRuleResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new AlertRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List AlertRuleResource resources by Watcher + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources + /// + /// + /// Operation Id + /// AlertRuleResource_ListByParent + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _alertRuleResourceRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _alertRuleResourceRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new AlertRuleResource(Client, AlertRuleResourceData.DeserializeAlertRuleResourceData(e)), _alertRuleResourceClientDiagnostics, Pipeline, "AlertRuleResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List AlertRuleResource resources by Watcher + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/alertRuleResources + /// + /// + /// Operation Id + /// AlertRuleResource_ListByParent + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _alertRuleResourceRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _alertRuleResourceRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new AlertRuleResource(Client, AlertRuleResourceData.DeserializeAlertRuleResourceData(e)), _alertRuleResourceClientDiagnostics, Pipeline, "AlertRuleResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string alertRuleResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); + + using var scope = _alertRuleResourceClientDiagnostics.CreateScope("AlertRuleResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _alertRuleResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string alertRuleResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); + + using var scope = _alertRuleResourceClientDiagnostics.CreateScope("AlertRuleResourceCollection.Exists"); + scope.Start(); + try + { + var response = _alertRuleResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string alertRuleResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); + + using var scope = _alertRuleResourceClientDiagnostics.CreateScope("AlertRuleResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _alertRuleResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new AlertRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string alertRuleResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(alertRuleResourceName, nameof(alertRuleResourceName)); + + using var scope = _alertRuleResourceClientDiagnostics.CreateScope("AlertRuleResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _alertRuleResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, alertRuleResourceName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new AlertRuleResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourceData.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourceData.Serialization.cs new file mode 100644 index 000000000000..080c88758721 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourceData.Serialization.cs @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + public partial class AlertRuleResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AlertRuleResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + AlertRuleResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AlertRuleResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAlertRuleResourceData(document.RootElement, options); + } + + internal static AlertRuleResourceData DeserializeAlertRuleResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AlertRuleResourceProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = AlertRuleResourceProperties.DeserializeAlertRuleResourceProperties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AlertRuleResourceData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AlertRuleResourceData)} does not support writing '{options.Format}' format."); + } + } + + AlertRuleResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAlertRuleResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AlertRuleResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourceData.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourceData.cs new file mode 100644 index 000000000000..496720664a3a --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/AlertRuleResourceData.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A class representing the AlertRuleResource data model. + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + /// + public partial class AlertRuleResourceData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public AlertRuleResourceData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal AlertRuleResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, AlertRuleResourceProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The resource-specific properties for this resource. + public AlertRuleResourceProperties Properties { get; set; } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/ArmDatabaseWatcherModelFactory.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/ArmDatabaseWatcherModelFactory.cs new file mode 100644 index 000000000000..338627741f12 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/ArmDatabaseWatcherModelFactory.cs @@ -0,0 +1,312 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// Model factory for models. + public static partial class ArmDatabaseWatcherModelFactory + { + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static SharedPrivateLinkResourceData SharedPrivateLinkResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, SharedPrivateLinkResourceProperties properties = null) + { + return new SharedPrivateLinkResourceData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// 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. + /// 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. + /// A new instance for mocking. + public static SharedPrivateLinkResourceProperties SharedPrivateLinkResourceProperties(ResourceIdentifier privateLinkResourceId = null, string groupId = null, string requestMessage = null, string dnsZone = null, SharedPrivateLinkResourceStatus? status = null, ResourceProvisioningState? provisioningState = null) + { + return new SharedPrivateLinkResourceProperties( + privateLinkResourceId, + groupId, + requestMessage, + dnsZone, + status, + provisioningState, + serializedAdditionalRawData: 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 . + /// + /// A new instance for mocking. + public static TargetData TargetData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, TargetProperties properties = null) + { + return new TargetData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Discriminator property for TargetProperties. + /// 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 TargetProperties TargetProperties(string targetType = null, TargetAuthenticationType targetAuthenticationType = default, VaultSecret targetVault = null, string connectionServerName = null, ResourceProvisioningState? provisioningState = null) + { + return new UnknownTargetProperties( + targetType, + targetAuthenticationType, + targetVault, + connectionServerName, + provisioningState, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// 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. + /// 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, VaultSecret targetVault = null, string connectionServerName = null, ResourceProvisioningState? provisioningState = null, ResourceIdentifier sqlDbResourceId = null, bool? readIntent = null) + { + return new SqlDbSingleDatabaseTargetProperties( + "SqlDb", + targetAuthenticationType, + targetVault, + connectionServerName, + provisioningState, + serializedAdditionalRawData: null, + sqlDbResourceId, + readIntent); + } + + /// Initializes a new instance of . + /// 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. + /// 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. + /// A new instance for mocking. + public static SqlDbElasticPoolTargetProperties SqlDbElasticPoolTargetProperties(TargetAuthenticationType targetAuthenticationType = default, VaultSecret targetVault = null, string connectionServerName = null, ResourceProvisioningState? provisioningState = null, ResourceIdentifier sqlEpResourceId = null, ResourceIdentifier anchorDatabaseResourceId = null, bool? readIntent = null) + { + return new SqlDbElasticPoolTargetProperties( + "SqlEp", + targetAuthenticationType, + targetVault, + connectionServerName, + provisioningState, + serializedAdditionalRawData: null, + sqlEpResourceId, + anchorDatabaseResourceId, + readIntent); + } + + /// Initializes a new instance of . + /// 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. + /// 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. + /// A new instance for mocking. + public static SqlMiTargetProperties SqlMiTargetProperties(TargetAuthenticationType targetAuthenticationType = default, VaultSecret targetVault = null, string connectionServerName = null, ResourceProvisioningState? provisioningState = null, ResourceIdentifier sqlMiResourceId = null, int? connectionTcpPort = null, bool? readIntent = null) + { + return new SqlMiTargetProperties( + "SqlMi", + targetAuthenticationType, + targetVault, + connectionServerName, + provisioningState, + serializedAdditionalRawData: null, + sqlMiResourceId, + connectionTcpPort, + readIntent); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static HealthValidationData HealthValidationData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, HealthValidationProperties properties = null) + { + return new HealthValidationData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// 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. + /// The provisioning state of the health validation resource. + /// A new instance for mocking. + public static HealthValidationProperties HealthValidationProperties(DateTimeOffset startOn = default, DateTimeOffset endOn = default, ValidationStatus status = default, IEnumerable issues = null, ResourceProvisioningState? provisioningState = null) + { + issues ??= new List(); + + return new HealthValidationProperties( + startOn, + endOn, + status, + issues?.ToList(), + provisioningState, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The error code of the issue. + /// The error message of the issue. + /// The additional details for the issue. + /// The recommendation for resolving the issue. + /// 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. + /// A new instance for mocking. + public static ValidationIssue ValidationIssue(string errorCode = null, string errorMessage = null, string additionalDetails = null, string recommendationMessage = null, Uri recommendationUri = null, ResourceIdentifier relatedResourceId = null, string relatedResourceType = null) + { + return new ValidationIssue( + errorCode, + errorMessage, + additionalDetails, + recommendationMessage, + recommendationUri, + relatedResourceId, + relatedResourceType, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static AlertRuleResourceData AlertRuleResourceData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, AlertRuleResourceProperties properties = null) + { + return new AlertRuleResourceData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// 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. + /// The provisioning state of the alert rule resource. + /// The template ID associated with alert rule resource. + /// The alert rule template version. + /// A new instance for mocking. + public static AlertRuleResourceProperties AlertRuleResourceProperties(ResourceIdentifier alertRuleResourceId = null, AlertRuleCreationProperty createdWithProperties = default, DateTimeOffset createdOn = default, ResourceProvisioningState? provisioningState = null, string alertRuleTemplateId = null, string alertRuleTemplateVersion = null) + { + return new AlertRuleResourceProperties( + alertRuleResourceId, + createdWithProperties, + createdOn, + provisioningState, + alertRuleTemplateId, + alertRuleTemplateVersion, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// The managed service identities assigned to this resource. + /// A new instance for mocking. + public static WatcherData WatcherData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, WatcherProperties properties = null, ManagedServiceIdentityV4 identity = null) + { + tags ??= new Dictionary(); + + return new WatcherData( + id, + name, + resourceType, + systemData, + tags, + location, + properties, + identity, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// 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 WatcherProperties WatcherProperties(Datastore datastore = null, WatcherStatus? status = null, DatabaseWatcherProvisioningState? provisioningState = null, ResourceIdentifier defaultAlertRuleIdentityResourceId = null) + { + return new WatcherProperties(datastore, status, provisioningState, defaultAlertRuleIdentityResourceId, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. + /// The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + /// The type of managed identity assigned to this resource. + /// The identities assigned to this resource by the user. + /// A new instance for mocking. + public static ManagedServiceIdentityV4 ManagedServiceIdentityV4(Guid? principalId = null, Guid? tenantId = null, ManagedServiceIdentityType type = default, IDictionary userAssignedIdentities = null) + { + userAssignedIdentities ??= new Dictionary(); + + return new ManagedServiceIdentityV4(principalId, tenantId, type, userAssignedIdentities, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/DatabaseWatcherExtensions.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/DatabaseWatcherExtensions.cs new file mode 100644 index 000000000000..6e392bbd6658 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/DatabaseWatcherExtensions.cs @@ -0,0 +1,295 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher.Mocking; +using Azure.ResourceManager.Resources; + +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)); + } + + private static MockableDatabaseWatcherResourceGroupResource GetMockableDatabaseWatcherResourceGroupResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableDatabaseWatcherResourceGroupResource(client, resource.Id)); + } + + private static MockableDatabaseWatcherSubscriptionResource GetMockableDatabaseWatcherSubscriptionResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableDatabaseWatcherSubscriptionResource(client, resource.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. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static WatcherResource GetWatcherResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDatabaseWatcherArmClient(client).GetWatcherResource(id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static AlertRuleResource GetAlertRuleResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDatabaseWatcherArmClient(client).GetAlertRuleResource(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. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static HealthValidationResource GetHealthValidationResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDatabaseWatcherArmClient(client).GetHealthValidationResource(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. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static TargetResource GetTargetResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDatabaseWatcherArmClient(client).GetTargetResource(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. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static SharedPrivateLinkResource GetSharedPrivateLinkResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableDatabaseWatcherArmClient(client).GetSharedPrivateLinkResource(id); + } + + /// + /// Gets a collection of WatcherResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// is null. + /// An object representing collection of WatcherResources and their operations over a WatcherResource. + public static WatcherCollection GetWatchers(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableDatabaseWatcherResourceGroupResource(resourceGroupResource).GetWatchers(); + } + + /// + /// 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. + /// The database watcher name. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetWatcherAsync(this ResourceGroupResource resourceGroupResource, string watcherName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableDatabaseWatcherResourceGroupResource(resourceGroupResource).GetWatcherAsync(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. + /// The database watcher name. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetWatcher(this ResourceGroupResource resourceGroupResource, string watcherName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableDatabaseWatcherResourceGroupResource(resourceGroupResource).GetWatcher(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. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetWatchersAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableDatabaseWatcherSubscriptionResource(subscriptionResource).GetWatchersAsync(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. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetWatchers(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableDatabaseWatcherSubscriptionResource(subscriptionResource).GetWatchers(cancellationToken); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherArmClient.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherArmClient.cs new file mode 100644 index 000000000000..43c0fc1c282d --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherArmClient.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableDatabaseWatcherArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableDatabaseWatcherArmClient() + { + } + + /// Initializes a new instance of the 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. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual WatcherResource GetWatcherResource(ResourceIdentifier id) + { + WatcherResource.ValidateResourceId(id); + return new WatcherResource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual AlertRuleResource GetAlertRuleResource(ResourceIdentifier id) + { + AlertRuleResource.ValidateResourceId(id); + return new AlertRuleResource(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. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual HealthValidationResource GetHealthValidationResource(ResourceIdentifier id) + { + HealthValidationResource.ValidateResourceId(id); + return new HealthValidationResource(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. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual TargetResource GetTargetResource(ResourceIdentifier id) + { + TargetResource.ValidateResourceId(id); + return new TargetResource(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. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual SharedPrivateLinkResource GetSharedPrivateLinkResource(ResourceIdentifier id) + { + SharedPrivateLinkResource.ValidateResourceId(id); + return new SharedPrivateLinkResource(Client, 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 new file mode 100644 index 000000000000..9efa41ebf78d --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherResourceGroupResource.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableDatabaseWatcherResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableDatabaseWatcherResourceGroupResource() + { + } + + /// Initializes a new instance of the 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 WatcherResources in the ResourceGroupResource. + /// An object representing collection of WatcherResources and their operations over a WatcherResource. + public virtual WatcherCollection GetWatchers() + { + return GetCachedClient(client => new WatcherCollection(client, Id)); + } + + /// + /// 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 + /// + /// + /// + /// + /// The database watcher name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetWatcherAsync(string watcherName, CancellationToken cancellationToken = default) + { + return await GetWatchers().GetAsync(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 + /// + /// + /// + /// + /// The database watcher name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetWatcher(string watcherName, CancellationToken cancellationToken = default) + { + return GetWatchers().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 new file mode 100644 index 000000000000..9b9e305ea5a0 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Extensions/MockableDatabaseWatcherSubscriptionResource.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.DatabaseWatcher.Mocking +{ + /// A class to add extension methods to SubscriptionResource. + public partial class MockableDatabaseWatcherSubscriptionResource : ArmResource + { + private ClientDiagnostics _watcherClientDiagnostics; + private WatchersRestOperations _watcherRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableDatabaseWatcherSubscriptionResource() + { + } + + /// Initializes a new instance of the 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 WatcherClientDiagnostics => _watcherClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", WatcherResource.ResourceType.Namespace, Diagnostics); + private WatchersRestOperations WatcherRestClient => _watcherRestClient ??= new WatchersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(WatcherResource.ResourceType)); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// 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 + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetWatchersAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => WatcherRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => WatcherRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new WatcherResource(Client, WatcherData.DeserializeWatcherData(e)), WatcherClientDiagnostics, Pipeline, "MockableDatabaseWatcherSubscriptionResource.GetWatchers", "value", "nextLink", 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 + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetWatchers(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => WatcherRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => WatcherRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new WatcherResource(Client, WatcherData.DeserializeWatcherData(e)), WatcherClientDiagnostics, Pipeline, "MockableDatabaseWatcherSubscriptionResource.GetWatchers", "value", "nextLink", cancellationToken); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationCollection.cs new file mode 100644 index 000000000000..b9af214f6894 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationCollection.cs @@ -0,0 +1,395 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetHealthValidations method from an instance of . + /// + public partial class HealthValidationCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _healthValidationClientDiagnostics; + private readonly HealthValidationsRestOperations _healthValidationRestClient; + + /// Initializes a new instance of the class for mocking. + protected HealthValidationCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal HealthValidationCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _healthValidationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", HealthValidationResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(HealthValidationResource.ResourceType, out string healthValidationApiVersion); + _healthValidationRestClient = new HealthValidationsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, healthValidationApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != WatcherResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, WatcherResource.ResourceType), nameof(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 an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string healthValidationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); + + using var scope = _healthValidationClientDiagnostics.CreateScope("HealthValidationCollection.Get"); + scope.Start(); + try + { + var response = await _healthValidationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, healthValidationName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new HealthValidationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string healthValidationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); + + using var scope = _healthValidationClientDiagnostics.CreateScope("HealthValidationCollection.Get"); + scope.Start(); + try + { + var response = _healthValidationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, healthValidationName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new HealthValidationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List HealthValidation resources by Watcher + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations + /// + /// + /// Operation Id + /// HealthValidation_ListByParent + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _healthValidationRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _healthValidationRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new HealthValidationResource(Client, HealthValidationData.DeserializeHealthValidationData(e)), _healthValidationClientDiagnostics, Pipeline, "HealthValidationCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List HealthValidation resources by Watcher + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations + /// + /// + /// Operation Id + /// HealthValidation_ListByParent + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _healthValidationRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _healthValidationRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new HealthValidationResource(Client, HealthValidationData.DeserializeHealthValidationData(e)), _healthValidationClientDiagnostics, Pipeline, "HealthValidationCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string healthValidationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); + + using var scope = _healthValidationClientDiagnostics.CreateScope("HealthValidationCollection.Exists"); + scope.Start(); + try + { + var response = await _healthValidationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, healthValidationName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string healthValidationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); + + using var scope = _healthValidationClientDiagnostics.CreateScope("HealthValidationCollection.Exists"); + scope.Start(); + try + { + var response = _healthValidationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, healthValidationName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string healthValidationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); + + using var scope = _healthValidationClientDiagnostics.CreateScope("HealthValidationCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _healthValidationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, healthValidationName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new HealthValidationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string healthValidationName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(healthValidationName, nameof(healthValidationName)); + + using var scope = _healthValidationClientDiagnostics.CreateScope("HealthValidationCollection.GetIfExists"); + scope.Start(); + try + { + var response = _healthValidationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, healthValidationName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new HealthValidationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationData.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationData.Serialization.cs new file mode 100644 index 000000000000..702adcb7971d --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationData.Serialization.cs @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + public partial class HealthValidationData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HealthValidationData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + HealthValidationData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HealthValidationData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHealthValidationData(document.RootElement, options); + } + + internal static HealthValidationData DeserializeHealthValidationData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + HealthValidationProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = HealthValidationProperties.DeserializeHealthValidationProperties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new HealthValidationData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(HealthValidationData)} does not support writing '{options.Format}' format."); + } + } + + HealthValidationData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeHealthValidationData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HealthValidationData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationData.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationData.cs new file mode 100644 index 000000000000..d261752d66de --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationData.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A class representing the HealthValidation data model. + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + /// + public partial class HealthValidationData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal HealthValidationData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal HealthValidationData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, HealthValidationProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The resource-specific properties for this resource. + public HealthValidationProperties Properties { get; } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationResource.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationResource.Serialization.cs new file mode 100644 index 000000000000..86d73ed6ee91 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + public partial class HealthValidationResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + HealthValidationData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + HealthValidationData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationResource.cs new file mode 100644 index 000000000000..c43c0dfacf3d --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/HealthValidationResource.cs @@ -0,0 +1,255 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A Class representing a HealthValidation 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 GetHealthValidationResource method. + /// Otherwise you can get one from its parent resource using the GetHealthValidation method. + /// + public partial class HealthValidationResource : 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 _healthValidationClientDiagnostics; + private readonly HealthValidationsRestOperations _healthValidationRestClient; + private readonly HealthValidationData _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. + protected HealthValidationResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal HealthValidationResource(ArmClient client, HealthValidationData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal HealthValidationResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _healthValidationClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string healthValidationApiVersion); + _healthValidationRestClient = new HealthValidationsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, healthValidationApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 HealthValidationData 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)); + } + + /// + /// 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 cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _healthValidationClientDiagnostics.CreateScope("HealthValidationResource.Get"); + scope.Start(); + try + { + var response = await _healthValidationRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new HealthValidationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _healthValidationClientDiagnostics.CreateScope("HealthValidationResource.Get"); + scope.Start(); + try + { + var response = _healthValidationRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new HealthValidationResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Starts health validation for a watcher. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}/startValidation + /// + /// + /// Operation Id + /// HealthValidations_StartValidation + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 cancellation token to use. + public virtual async Task> StartValidationAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _healthValidationClientDiagnostics.CreateScope("HealthValidationResource.StartValidation"); + scope.Start(); + try + { + var response = await _healthValidationRestClient.StartValidationAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new DatabaseWatcherArmOperation(new HealthValidationOperationSource(Client), _healthValidationClientDiagnostics, Pipeline, _healthValidationRestClient.CreateStartValidationRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Starts health validation for a watcher. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/healthValidations/{healthValidationName}/startValidation + /// + /// + /// Operation Id + /// HealthValidations_StartValidation + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 cancellation token to use. + public virtual ArmOperation StartValidation(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _healthValidationClientDiagnostics.CreateScope("HealthValidationResource.StartValidation"); + scope.Start(); + try + { + var response = _healthValidationRestClient.StartValidation(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new DatabaseWatcherArmOperation(new HealthValidationOperationSource(Client), _healthValidationClientDiagnostics, Pipeline, _healthValidationRestClient.CreateStartValidationRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + 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 new file mode 100644 index 000000000000..32f9b26aaec4 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Argument.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal static class Argument + { + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + 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/ChangeTrackingDictionary.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..6afbde7e464c --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + public bool IsUndefined => _innerDictionary == null; + + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + IEnumerable IReadOnlyDictionary.Keys => Keys; + + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ChangeTrackingList.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..7d07be2128e8 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + public bool IsUndefined => _innerList == null; + + public int Count => IsUndefined ? 0 : EnsureList().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..042bb5f708f5 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,398 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal static class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var 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(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + 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"); + } + + public static string GetRequiredString(this JsonElement element) + { + var 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}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + 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 new file mode 100644 index 000000000000..78fe76f53503 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal static class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..e46e08cbf3ee --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + 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; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherArmOperation.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherArmOperation.cs new file mode 100644 index 000000000000..0380185acc37 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherArmOperation.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +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 + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of DatabaseWatcherArmOperation for mocking. + protected DatabaseWatcherArmOperation() + { + } + + internal DatabaseWatcherArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + 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) + { + _nextLinkOperation = nextLinkOperationValue; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "DatabaseWatcherArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json).ToObjectFromJson>(); + return lroDetails["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 new file mode 100644 index 000000000000..7bc2029706fc --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/DatabaseWatcherArmOperationOfT.cs @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +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 + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of DatabaseWatcherArmOperation for mocking. + protected DatabaseWatcherArmOperation() + { + } + + internal DatabaseWatcherArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + 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) + { + _nextLinkOperation = nextLinkOperationValue; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _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()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json).ToObjectFromJson>(); + return lroDetails["id"]; + } + /// + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override T Value => _operation.Value; + + /// + public override bool HasValue => _operation.HasValue; + + /// + 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 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/HealthValidationOperationSource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/HealthValidationOperationSource.cs new file mode 100644 index 000000000000..1db65fe7c9b6 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/HealthValidationOperationSource.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal class HealthValidationOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal HealthValidationOperationSource(ArmClient client) + { + _client = client; + } + + HealthValidationResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = HealthValidationData.DeserializeHealthValidationData(document.RootElement); + return new HealthValidationResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = HealthValidationData.DeserializeHealthValidationData(document.RootElement); + return new HealthValidationResource(_client, data); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/SharedPrivateLinkResourceOperationSource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/SharedPrivateLinkResourceOperationSource.cs new file mode 100644 index 000000000000..eb2d0282f266 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/SharedPrivateLinkResourceOperationSource.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal class SharedPrivateLinkResourceOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal SharedPrivateLinkResourceOperationSource(ArmClient client) + { + _client = client; + } + + SharedPrivateLinkResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = SharedPrivateLinkResourceData.DeserializeSharedPrivateLinkResourceData(document.RootElement); + return new SharedPrivateLinkResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = SharedPrivateLinkResourceData.DeserializeSharedPrivateLinkResourceData(document.RootElement); + return new SharedPrivateLinkResource(_client, data); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/WatcherOperationSource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/WatcherOperationSource.cs new file mode 100644 index 000000000000..31cbf348dae8 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/LongRunningOperation/WatcherOperationSource.cs @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal class WatcherOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal WatcherOperationSource(ArmClient client) + { + _client = client; + } + + WatcherResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = WatcherData.DeserializeWatcherData(document.RootElement); + return new WatcherResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = WatcherData.DeserializeWatcherData(document.RootElement); + return new WatcherResource(_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 new file mode 100644 index 000000000000..182479a7ce69 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleCreationProperty.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The properties with which the alert rule resource was created. + public readonly partial struct AlertRuleCreationProperty : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AlertRuleCreationProperty(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CreatedWithActionGroupValue = "CreatedWithActionGroup"; + private const string NoneValue = "None"; + + /// 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. + public static bool operator ==(AlertRuleCreationProperty left, AlertRuleCreationProperty right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AlertRuleCreationProperty left, AlertRuleCreationProperty right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AlertRuleCreationProperty(string value) => 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 new file mode 100644 index 000000000000..4b6de8bfbc13 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceListResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + internal partial class AlertRuleResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AlertRuleResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AlertRuleResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(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) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AlertRuleResourceData.DeserializeAlertRuleResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AlertRuleResourceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AlertRuleResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + AlertRuleResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAlertRuleResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AlertRuleResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceListResult.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceListResult.cs new file mode 100644 index 000000000000..3a2a86a9d0e8 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.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; + + /// 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) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AlertRuleResourceListResult() + { + } + + /// The AlertRuleResource items on this page. + public IReadOnlyList 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/AlertRuleResourceProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceProperties.Serialization.cs new file mode 100644 index 000000000000..04ae44267dbc --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceProperties.Serialization.cs @@ -0,0 +1,180 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + public partial class AlertRuleResourceProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AlertRuleResourceProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("alertRuleResourceId"u8); + writer.WriteStringValue(AlertRuleResourceId); + writer.WritePropertyName("createdWithProperties"u8); + writer.WriteStringValue(CreatedWithProperties.ToString()); + writer.WritePropertyName("creationTime"u8); + writer.WriteStringValue(CreatedOn, "O"); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + writer.WritePropertyName("alertRuleTemplateId"u8); + writer.WriteStringValue(AlertRuleTemplateId); + writer.WritePropertyName("alertRuleTemplateVersion"u8); + writer.WriteStringValue(AlertRuleTemplateVersion); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AlertRuleResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AlertRuleResourceProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAlertRuleResourceProperties(document.RootElement, options); + } + + internal static AlertRuleResourceProperties DeserializeAlertRuleResourceProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier alertRuleResourceId = default; + AlertRuleCreationProperty createdWithProperties = default; + DateTimeOffset creationTime = default; + ResourceProvisioningState? provisioningState = default; + string alertRuleTemplateId = default; + string alertRuleTemplateVersion = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("alertRuleResourceId"u8)) + { + alertRuleResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("createdWithProperties"u8)) + { + createdWithProperties = new AlertRuleCreationProperty(property.Value.GetString()); + continue; + } + if (property.NameEquals("creationTime"u8)) + { + creationTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ResourceProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("alertRuleTemplateId"u8)) + { + alertRuleTemplateId = property.Value.GetString(); + continue; + } + if (property.NameEquals("alertRuleTemplateVersion"u8)) + { + alertRuleTemplateVersion = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AlertRuleResourceProperties( + alertRuleResourceId, + createdWithProperties, + creationTime, + provisioningState, + alertRuleTemplateId, + alertRuleTemplateVersion, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AlertRuleResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + AlertRuleResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAlertRuleResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AlertRuleResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceProperties.cs new file mode 100644 index 000000000000..81d7429e72f0 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/AlertRuleResourceProperties.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The generic properties of the alert rule proxy resource. + public partial class AlertRuleResourceProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The 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. + /// The template ID associated with alert rule resource. + /// The alert rule template version. + /// , or is null. + public AlertRuleResourceProperties(ResourceIdentifier alertRuleResourceId, AlertRuleCreationProperty createdWithProperties, DateTimeOffset createdOn, string alertRuleTemplateId, string alertRuleTemplateVersion) + { + Argument.AssertNotNull(alertRuleResourceId, nameof(alertRuleResourceId)); + Argument.AssertNotNull(alertRuleTemplateId, nameof(alertRuleTemplateId)); + Argument.AssertNotNull(alertRuleTemplateVersion, nameof(alertRuleTemplateVersion)); + + AlertRuleResourceId = alertRuleResourceId; + CreatedWithProperties = createdWithProperties; + CreatedOn = createdOn; + AlertRuleTemplateId = alertRuleTemplateId; + AlertRuleTemplateVersion = alertRuleTemplateVersion; + } + + /// Initializes a new instance of . + /// 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. + /// 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 AlertRuleResourceProperties(ResourceIdentifier alertRuleResourceId, AlertRuleCreationProperty createdWithProperties, DateTimeOffset createdOn, ResourceProvisioningState? provisioningState, string alertRuleTemplateId, string alertRuleTemplateVersion, IDictionary serializedAdditionalRawData) + { + AlertRuleResourceId = alertRuleResourceId; + CreatedWithProperties = createdWithProperties; + CreatedOn = createdOn; + ProvisioningState = provisioningState; + AlertRuleTemplateId = alertRuleTemplateId; + AlertRuleTemplateVersion = alertRuleTemplateVersion; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AlertRuleResourceProperties() + { + } + + /// 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 ResourceProvisioningState? 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/DatabaseWatcherProvisioningState.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherProvisioningState.cs new file mode 100644 index 000000000000..1d26cbf74b16 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/DatabaseWatcherProvisioningState.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The status of the last provisioning operation performed on the resource. + public readonly partial struct DatabaseWatcherProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DatabaseWatcherProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + + /// 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. + public static bool operator ==(DatabaseWatcherProvisioningState left, DatabaseWatcherProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DatabaseWatcherProvisioningState left, DatabaseWatcherProvisioningState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DatabaseWatcherProvisioningState(string value) => 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/Datastore.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/Datastore.Serialization.cs new file mode 100644 index 000000000000..d2a52e768ada --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/Datastore.Serialization.cs @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + public partial class Datastore : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Datastore)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(AdxClusterResourceId)) + { + writer.WritePropertyName("adxClusterResourceId"u8); + writer.WriteStringValue(AdxClusterResourceId); + } + if (Optional.IsDefined(KustoClusterDisplayName)) + { + writer.WritePropertyName("kustoClusterDisplayName"u8); + writer.WriteStringValue(KustoClusterDisplayName); + } + writer.WritePropertyName("kustoClusterUri"u8); + writer.WriteStringValue(KustoClusterUri); + writer.WritePropertyName("kustoDataIngestionUri"u8); + writer.WriteStringValue(KustoDataIngestionUri); + writer.WritePropertyName("kustoDatabaseName"u8); + writer.WriteStringValue(KustoDatabaseName); + writer.WritePropertyName("kustoManagementUrl"u8); + writer.WriteStringValue(KustoManagementUri); + writer.WritePropertyName("kustoOfferingType"u8); + writer.WriteStringValue(KustoOfferingType.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Datastore IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Datastore)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDatastore(document.RootElement, options); + } + + internal static Datastore DeserializeDatastore(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier adxClusterResourceId = default; + string kustoClusterDisplayName = default; + string kustoClusterUri = default; + string kustoDataIngestionUri = default; + string kustoDatabaseName = default; + string kustoManagementUrl = default; + KustoOfferingType kustoOfferingType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("adxClusterResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + adxClusterResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("kustoClusterDisplayName"u8)) + { + kustoClusterDisplayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("kustoClusterUri"u8)) + { + kustoClusterUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("kustoDataIngestionUri"u8)) + { + kustoDataIngestionUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("kustoDatabaseName"u8)) + { + kustoDatabaseName = property.Value.GetString(); + continue; + } + if (property.NameEquals("kustoManagementUrl"u8)) + { + kustoManagementUrl = property.Value.GetString(); + continue; + } + if (property.NameEquals("kustoOfferingType"u8)) + { + kustoOfferingType = new KustoOfferingType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Datastore( + adxClusterResourceId, + kustoClusterDisplayName, + kustoClusterUri, + kustoDataIngestionUri, + kustoDatabaseName, + kustoManagementUrl, + kustoOfferingType, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Datastore)} does not support writing '{options.Format}' format."); + } + } + + Datastore IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDatastore(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Datastore)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/Datastore.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/Datastore.cs new file mode 100644 index 000000000000..a5fb7745f3a7 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/Datastore.cs @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The properties of a data store. + public partial class Datastore + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The Kusto cluster URI. + /// The Kusto data ingestion URI. + /// The name of a Kusto database. + /// The Kusto management URL. + /// The type of a Kusto offering. + /// , , or is null. + public Datastore(string kustoClusterUri, string kustoDataIngestionUri, string kustoDatabaseName, string kustoManagementUri, KustoOfferingType kustoOfferingType) + { + Argument.AssertNotNull(kustoClusterUri, nameof(kustoClusterUri)); + Argument.AssertNotNull(kustoDataIngestionUri, nameof(kustoDataIngestionUri)); + Argument.AssertNotNull(kustoDatabaseName, nameof(kustoDatabaseName)); + Argument.AssertNotNull(kustoManagementUri, nameof(kustoManagementUri)); + + KustoClusterUri = kustoClusterUri; + KustoDataIngestionUri = kustoDataIngestionUri; + KustoDatabaseName = kustoDatabaseName; + KustoManagementUri = kustoManagementUri; + KustoOfferingType = kustoOfferingType; + } + + /// Initializes a new instance of . + /// The Azure resource ID of an Azure Data Explorer cluster. + /// The Kusto cluster display name. + /// The Kusto cluster URI. + /// The Kusto data ingestion URI. + /// 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 Datastore(ResourceIdentifier adxClusterResourceId, string kustoClusterDisplayName, string kustoClusterUri, string kustoDataIngestionUri, string kustoDatabaseName, string kustoManagementUri, KustoOfferingType kustoOfferingType, IDictionary serializedAdditionalRawData) + { + AdxClusterResourceId = adxClusterResourceId; + KustoClusterDisplayName = kustoClusterDisplayName; + KustoClusterUri = kustoClusterUri; + KustoDataIngestionUri = kustoDataIngestionUri; + KustoDatabaseName = kustoDatabaseName; + KustoManagementUri = kustoManagementUri; + KustoOfferingType = kustoOfferingType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Datastore() + { + } + + /// 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 string KustoClusterUri { get; set; } + /// The Kusto data ingestion URI. + public string KustoDataIngestionUri { get; set; } + /// The name of a Kusto database. + public string KustoDatabaseName { get; set; } + /// The Kusto management URL. + public string 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/HealthValidationListResult.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationListResult.Serialization.cs new file mode 100644 index 000000000000..c9bb89b1a451 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationListResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + internal partial class HealthValidationListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HealthValidationListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + HealthValidationListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(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) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(HealthValidationData.DeserializeHealthValidationData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new HealthValidationListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(HealthValidationListResult)} does not support writing '{options.Format}' format."); + } + } + + HealthValidationListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeHealthValidationListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HealthValidationListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationListResult.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationListResult.cs new file mode 100644 index 000000000000..7de6b1d74262 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.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; + + /// 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) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal HealthValidationListResult() + { + } + + /// The HealthValidation items on this page. + public IReadOnlyList 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/HealthValidationProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationProperties.Serialization.cs new file mode 100644 index 000000000000..3c80423b8ade --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationProperties.Serialization.cs @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + public partial class HealthValidationProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HealthValidationProperties)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("startTime"u8); + writer.WriteStringValue(StartOn, "O"); + } + if (options.Format != "W") + { + writer.WritePropertyName("endTime"u8); + writer.WriteStringValue(EndOn, "O"); + } + if (options.Format != "W") + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + } + if (options.Format != "W") + { + writer.WritePropertyName("issues"u8); + writer.WriteStartArray(); + foreach (var item in Issues) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + HealthValidationProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HealthValidationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHealthValidationProperties(document.RootElement, options); + } + + internal static HealthValidationProperties DeserializeHealthValidationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset startTime = default; + DateTimeOffset endTime = default; + ValidationStatus status = default; + IReadOnlyList issues = default; + ResourceProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("startTime"u8)) + { + startTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("endTime"u8)) + { + endTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new ValidationStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("issues"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ValidationIssue.DeserializeValidationIssue(item, options)); + } + issues = array; + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ResourceProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new HealthValidationProperties( + startTime, + endTime, + status, + issues, + provisioningState, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(HealthValidationProperties)} does not support writing '{options.Format}' format."); + } + } + + HealthValidationProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeHealthValidationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HealthValidationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationProperties.cs new file mode 100644 index 000000000000..963f55c00df1 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/HealthValidationProperties.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The generic properties of the health validation resource. + public partial class HealthValidationProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The 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 HealthValidationProperties(DateTimeOffset startOn, DateTimeOffset endOn, ValidationStatus status, IEnumerable issues) + { + StartOn = startOn; + EndOn = endOn; + Status = status; + Issues = issues.ToList(); + } + + /// 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. + /// The provisioning state of the health validation resource. + /// Keeps track of any properties unknown to the library. + internal HealthValidationProperties(DateTimeOffset startOn, DateTimeOffset endOn, ValidationStatus status, IReadOnlyList issues, ResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + StartOn = startOn; + EndOn = endOn; + Status = status; + Issues = issues; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal HealthValidationProperties() + { + } + + /// 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 ValidationStatus Status { get; } + /// The list of issues found by health validation. + public IReadOnlyList Issues { get; } + /// The provisioning state of the health validation resource. + public ResourceProvisioningState? ProvisioningState { 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 new file mode 100644 index 000000000000..5650f0cb4d19 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/KustoOfferingType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The type of Kusto offering. + public readonly partial struct KustoOfferingType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public KustoOfferingType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AdxValue = "adx"; + private const string FreeValue = "free"; + private const string FabricValue = "fabric"; + + /// 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. + public static bool operator ==(KustoOfferingType left, KustoOfferingType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(KustoOfferingType left, KustoOfferingType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator KustoOfferingType(string value) => 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/ManagedServiceIdentityType.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ManagedServiceIdentityType.cs new file mode 100644 index 000000000000..bf830748c396 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ManagedServiceIdentityType.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + public readonly partial struct ManagedServiceIdentityType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ManagedServiceIdentityType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string SystemAssignedValue = "SystemAssigned"; + private const string UserAssignedValue = "UserAssigned"; + private const string SystemAndUserAssignedValue = "SystemAssigned, UserAssigned"; + + /// No managed identity. + public static ManagedServiceIdentityType None { get; } = new ManagedServiceIdentityType(NoneValue); + /// System assigned managed identity. + public static ManagedServiceIdentityType SystemAssigned { get; } = new ManagedServiceIdentityType(SystemAssignedValue); + /// User assigned managed identity. + public static ManagedServiceIdentityType UserAssigned { get; } = new ManagedServiceIdentityType(UserAssignedValue); + /// System and user assigned managed identity. + public static ManagedServiceIdentityType SystemAndUserAssigned { get; } = new ManagedServiceIdentityType(SystemAndUserAssignedValue); + /// Determines if two values are the same. + public static bool operator ==(ManagedServiceIdentityType left, ManagedServiceIdentityType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ManagedServiceIdentityType left, ManagedServiceIdentityType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ManagedServiceIdentityType(string value) => new ManagedServiceIdentityType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ManagedServiceIdentityType other && Equals(other); + /// + public bool Equals(ManagedServiceIdentityType 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/ManagedServiceIdentityV4.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ManagedServiceIdentityV4.Serialization.cs new file mode 100644 index 000000000000..6f6c061eb3c8 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ManagedServiceIdentityV4.Serialization.cs @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + public partial class ManagedServiceIdentityV4 : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedServiceIdentityV4)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(PrincipalId)) + { + writer.WritePropertyName("principalId"u8); + writer.WriteStringValue(PrincipalId.Value); + } + if (options.Format != "W" && Optional.IsDefined(TenantId)) + { + writer.WritePropertyName("tenantId"u8); + writer.WriteStringValue(TenantId.Value); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (Optional.IsCollectionDefined(UserAssignedIdentities)) + { + writer.WritePropertyName("userAssignedIdentities"u8); + writer.WriteStartObject(); + foreach (var item in UserAssignedIdentities) + { + writer.WritePropertyName(item.Key); + JsonSerializer.Serialize(writer, item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ManagedServiceIdentityV4 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedServiceIdentityV4)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedServiceIdentityV4(document.RootElement, options); + } + + internal static ManagedServiceIdentityV4 DeserializeManagedServiceIdentityV4(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Guid? principalId = default; + Guid? tenantId = default; + ManagedServiceIdentityType type = default; + IDictionary userAssignedIdentities = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("principalId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + principalId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("tenantId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + tenantId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ManagedServiceIdentityType(property.Value.GetString()); + continue; + } + if (property.NameEquals("userAssignedIdentities"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, JsonSerializer.Deserialize(property0.Value.GetRawText())); + } + userAssignedIdentities = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedServiceIdentityV4(principalId, tenantId, type, userAssignedIdentities ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ManagedServiceIdentityV4)} does not support writing '{options.Format}' format."); + } + } + + ManagedServiceIdentityV4 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeManagedServiceIdentityV4(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedServiceIdentityV4)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ManagedServiceIdentityV4.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ManagedServiceIdentityV4.cs new file mode 100644 index 000000000000..284c3a903ae7 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ManagedServiceIdentityV4.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// Managed service identity (system assigned and/or user assigned identities). + public partial class ManagedServiceIdentityV4 + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The type of managed identity assigned to this resource. + public ManagedServiceIdentityV4(ManagedServiceIdentityType type) + { + Type = type; + UserAssignedIdentities = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. + /// The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + /// The type of managed identity assigned to this resource. + /// The identities assigned to this resource by the user. + /// Keeps track of any properties unknown to the library. + internal ManagedServiceIdentityV4(Guid? principalId, Guid? tenantId, ManagedServiceIdentityType type, IDictionary userAssignedIdentities, IDictionary serializedAdditionalRawData) + { + PrincipalId = principalId; + TenantId = tenantId; + Type = type; + UserAssignedIdentities = userAssignedIdentities; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ManagedServiceIdentityV4() + { + } + + /// The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. + public Guid? PrincipalId { get; } + /// The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + public Guid? TenantId { get; } + /// The type of managed identity assigned to this resource. + public ManagedServiceIdentityType Type { get; set; } + /// The identities assigned to this resource by the user. + public IDictionary UserAssignedIdentities { get; } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ResourceProvisioningState.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ResourceProvisioningState.cs new file mode 100644 index 000000000000..ef613439b6ab --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ResourceProvisioningState.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The provisioning state of a resource type. + public readonly partial struct ResourceProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ResourceProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + + /// Resource has been created. + public static ResourceProvisioningState Succeeded { get; } = new ResourceProvisioningState(SucceededValue); + /// Resource creation failed. + public static ResourceProvisioningState Failed { get; } = new ResourceProvisioningState(FailedValue); + /// Resource creation was canceled. + public static ResourceProvisioningState Canceled { get; } = new ResourceProvisioningState(CanceledValue); + /// Determines if two values are the same. + public static bool operator ==(ResourceProvisioningState left, ResourceProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ResourceProvisioningState left, ResourceProvisioningState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ResourceProvisioningState(string value) => new ResourceProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResourceProvisioningState other && Equals(other); + /// + public bool Equals(ResourceProvisioningState 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 new file mode 100644 index 000000000000..d5dd91e594f4 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceListResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + internal partial class SharedPrivateLinkResourceListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharedPrivateLinkResourceListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SharedPrivateLinkResourceListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(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) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SharedPrivateLinkResourceData.DeserializeSharedPrivateLinkResourceData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SharedPrivateLinkResourceListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SharedPrivateLinkResourceListResult)} does not support writing '{options.Format}' format."); + } + } + + SharedPrivateLinkResourceListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSharedPrivateLinkResourceListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SharedPrivateLinkResourceListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceListResult.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceListResult.cs new file mode 100644 index 000000000000..bc7a9e3ee202 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.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; + + /// 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) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SharedPrivateLinkResourceListResult() + { + } + + /// The SharedPrivateLinkResource items on this page. + public IReadOnlyList 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/SharedPrivateLinkResourceProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceProperties.Serialization.cs new file mode 100644 index 000000000000..188661a910af --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceProperties.Serialization.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + public partial class SharedPrivateLinkResourceProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharedPrivateLinkResourceProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("privateLinkResourceId"u8); + writer.WriteStringValue(PrivateLinkResourceId); + writer.WritePropertyName("groupId"u8); + writer.WriteStringValue(GroupId); + writer.WritePropertyName("requestMessage"u8); + writer.WriteStringValue(RequestMessage); + if (Optional.IsDefined(DnsZone)) + { + writer.WritePropertyName("dnsZone"u8); + writer.WriteStringValue(DnsZone); + } + if (options.Format != "W" && Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SharedPrivateLinkResourceProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharedPrivateLinkResourceProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSharedPrivateLinkResourceProperties(document.RootElement, options); + } + + internal static SharedPrivateLinkResourceProperties DeserializeSharedPrivateLinkResourceProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier privateLinkResourceId = default; + string groupId = default; + string requestMessage = default; + string dnsZone = default; + SharedPrivateLinkResourceStatus? status = default; + ResourceProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("privateLinkResourceId"u8)) + { + privateLinkResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("groupId"u8)) + { + groupId = property.Value.GetString(); + continue; + } + if (property.NameEquals("requestMessage"u8)) + { + requestMessage = property.Value.GetString(); + continue; + } + if (property.NameEquals("dnsZone"u8)) + { + dnsZone = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new SharedPrivateLinkResourceStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ResourceProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SharedPrivateLinkResourceProperties( + privateLinkResourceId, + groupId, + requestMessage, + dnsZone, + status, + provisioningState, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SharedPrivateLinkResourceProperties)} does not support writing '{options.Format}' format."); + } + } + + SharedPrivateLinkResourceProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSharedPrivateLinkResourceProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SharedPrivateLinkResourceProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceProperties.cs new file mode 100644 index 000000000000..e7a80cc7cca3 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceProperties.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The generic properties of a Shared Private Link resource. + public partial class SharedPrivateLinkResourceProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The 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. + /// , or is null. + public SharedPrivateLinkResourceProperties(ResourceIdentifier privateLinkResourceId, string groupId, string requestMessage) + { + Argument.AssertNotNull(privateLinkResourceId, nameof(privateLinkResourceId)); + Argument.AssertNotNull(groupId, nameof(groupId)); + Argument.AssertNotNull(requestMessage, nameof(requestMessage)); + + PrivateLinkResourceId = privateLinkResourceId; + GroupId = groupId; + RequestMessage = requestMessage; + } + + /// Initializes a new instance of . + /// 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. + /// 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 SharedPrivateLinkResourceProperties(ResourceIdentifier privateLinkResourceId, string groupId, string requestMessage, string dnsZone, SharedPrivateLinkResourceStatus? status, ResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + PrivateLinkResourceId = privateLinkResourceId; + GroupId = groupId; + RequestMessage = requestMessage; + DnsZone = dnsZone; + Status = status; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SharedPrivateLinkResourceProperties() + { + } + + /// 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 SharedPrivateLinkResourceStatus? Status { get; } + /// The provisioning state of the resource. + public ResourceProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceStatus.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceStatus.cs new file mode 100644 index 000000000000..b0ac514fd1d4 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SharedPrivateLinkResourceStatus.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// Status of the shared private link resource. Can be Pending, Approved, Rejected or Disconnected. + public readonly partial struct SharedPrivateLinkResourceStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SharedPrivateLinkResourceStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PendingValue = "Pending"; + private const string ApprovedValue = "Approved"; + private const string RejectedValue = "Rejected"; + private const string DisconnectedValue = "Disconnected"; + + /// The shared private link connection request was not yet authorized by the resource owner. + public static SharedPrivateLinkResourceStatus Pending { get; } = new SharedPrivateLinkResourceStatus(PendingValue); + /// The shared private link connection request was approved by the resource owner. + public static SharedPrivateLinkResourceStatus Approved { get; } = new SharedPrivateLinkResourceStatus(ApprovedValue); + /// The shared private link connection request was rejected by the resource owner. + public static SharedPrivateLinkResourceStatus Rejected { get; } = new SharedPrivateLinkResourceStatus(RejectedValue); + /// The shared private link connection request was disconnected by the resource owner. + public static SharedPrivateLinkResourceStatus Disconnected { get; } = new SharedPrivateLinkResourceStatus(DisconnectedValue); + /// Determines if two values are the same. + public static bool operator ==(SharedPrivateLinkResourceStatus left, SharedPrivateLinkResourceStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SharedPrivateLinkResourceStatus left, SharedPrivateLinkResourceStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator SharedPrivateLinkResourceStatus(string value) => new SharedPrivateLinkResourceStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SharedPrivateLinkResourceStatus other && Equals(other); + /// + public bool Equals(SharedPrivateLinkResourceStatus 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/SqlDbElasticPoolTargetProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDbElasticPoolTargetProperties.Serialization.cs new file mode 100644 index 000000000000..4573e62e8fdb --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDbElasticPoolTargetProperties.Serialization.cs @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + public partial class SqlDbElasticPoolTargetProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SqlDbElasticPoolTargetProperties)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("sqlEpResourceId"u8); + writer.WriteStringValue(SqlEpResourceId); + writer.WritePropertyName("anchorDatabaseResourceId"u8); + writer.WriteStringValue(AnchorDatabaseResourceId); + if (Optional.IsDefined(ReadIntent)) + { + writer.WritePropertyName("readIntent"u8); + writer.WriteBooleanValue(ReadIntent.Value); + } + } + + SqlDbElasticPoolTargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(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) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier sqlEpResourceId = default; + ResourceIdentifier anchorDatabaseResourceId = default; + bool? readIntent = default; + string targetType = default; + TargetAuthenticationType targetAuthenticationType = default; + VaultSecret targetVault = default; + string connectionServerName = default; + ResourceProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sqlEpResourceId"u8)) + { + sqlEpResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("anchorDatabaseResourceId"u8)) + { + anchorDatabaseResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("readIntent"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + readIntent = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("targetType"u8)) + { + targetType = property.Value.GetString(); + continue; + } + if (property.NameEquals("targetAuthenticationType"u8)) + { + targetAuthenticationType = new TargetAuthenticationType(property.Value.GetString()); + continue; + } + if (property.NameEquals("targetVault"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetVault = VaultSecret.DeserializeVaultSecret(property.Value, options); + continue; + } + if (property.NameEquals("connectionServerName"u8)) + { + connectionServerName = property.Value.GetString(); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ResourceProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SqlDbElasticPoolTargetProperties( + targetType, + targetAuthenticationType, + targetVault, + connectionServerName, + provisioningState, + serializedAdditionalRawData, + sqlEpResourceId, + anchorDatabaseResourceId, + readIntent); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SqlDbElasticPoolTargetProperties)} does not support writing '{options.Format}' format."); + } + } + + SqlDbElasticPoolTargetProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSqlDbElasticPoolTargetProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SqlDbElasticPoolTargetProperties)} does not support reading '{options.Format}' format."); + } + } + + 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 new file mode 100644 index 000000000000..3b1bc634e486 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDbElasticPoolTargetProperties.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The properties specific to an elastic pool in Azure SQL Database. + public partial class SqlDbElasticPoolTargetProperties : TargetProperties + { + /// Initializes a new instance of . + /// 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. + /// 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) + { + Argument.AssertNotNull(connectionServerName, nameof(connectionServerName)); + Argument.AssertNotNull(sqlEpResourceId, nameof(sqlEpResourceId)); + Argument.AssertNotNull(anchorDatabaseResourceId, nameof(anchorDatabaseResourceId)); + + SqlEpResourceId = sqlEpResourceId; + AnchorDatabaseResourceId = anchorDatabaseResourceId; + TargetType = "SqlEp"; + } + + /// Initializes a new instance of . + /// Discriminator property for TargetProperties. + /// 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. + /// 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, VaultSecret targetVault, string connectionServerName, ResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData, ResourceIdentifier sqlEpResourceId, ResourceIdentifier anchorDatabaseResourceId, bool? readIntent) : base(targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, serializedAdditionalRawData) + { + 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 new file mode 100644 index 000000000000..f43750b9adfa --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDbSingleDatabaseTargetProperties.Serialization.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + public partial class SqlDbSingleDatabaseTargetProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SqlDbSingleDatabaseTargetProperties)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("sqlDbResourceId"u8); + writer.WriteStringValue(SqlDbResourceId); + if (Optional.IsDefined(ReadIntent)) + { + writer.WritePropertyName("readIntent"u8); + writer.WriteBooleanValue(ReadIntent.Value); + } + } + + SqlDbSingleDatabaseTargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(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) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier sqlDbResourceId = default; + bool? readIntent = default; + string targetType = default; + TargetAuthenticationType targetAuthenticationType = default; + VaultSecret targetVault = default; + string connectionServerName = default; + ResourceProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sqlDbResourceId"u8)) + { + sqlDbResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("readIntent"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + readIntent = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("targetType"u8)) + { + targetType = property.Value.GetString(); + continue; + } + if (property.NameEquals("targetAuthenticationType"u8)) + { + targetAuthenticationType = new TargetAuthenticationType(property.Value.GetString()); + continue; + } + if (property.NameEquals("targetVault"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetVault = VaultSecret.DeserializeVaultSecret(property.Value, options); + continue; + } + if (property.NameEquals("connectionServerName"u8)) + { + connectionServerName = property.Value.GetString(); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ResourceProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SqlDbSingleDatabaseTargetProperties( + targetType, + targetAuthenticationType, + targetVault, + connectionServerName, + provisioningState, + serializedAdditionalRawData, + sqlDbResourceId, + readIntent); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SqlDbSingleDatabaseTargetProperties)} does not support writing '{options.Format}' format."); + } + } + + SqlDbSingleDatabaseTargetProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSqlDbSingleDatabaseTargetProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SqlDbSingleDatabaseTargetProperties)} does not support reading '{options.Format}' format."); + } + } + + 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 new file mode 100644 index 000000000000..e91b17ceb4bc --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlDbSingleDatabaseTargetProperties.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The properties specific to a database in Azure SQL Database. + public partial class SqlDbSingleDatabaseTargetProperties : TargetProperties + { + /// Initializes a new instance of . + /// 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. + /// 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) + { + Argument.AssertNotNull(connectionServerName, nameof(connectionServerName)); + Argument.AssertNotNull(sqlDbResourceId, nameof(sqlDbResourceId)); + + SqlDbResourceId = sqlDbResourceId; + TargetType = "SqlDb"; + } + + /// Initializes a new instance of . + /// Discriminator property for TargetProperties. + /// 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. + /// 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, VaultSecret targetVault, string connectionServerName, ResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData, ResourceIdentifier sqlDbResourceId, bool? readIntent) : base(targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, serializedAdditionalRawData) + { + 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 new file mode 100644 index 000000000000..5689a5a1dceb --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlMiTargetProperties.Serialization.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + public partial class SqlMiTargetProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SqlMiTargetProperties)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("sqlMiResourceId"u8); + writer.WriteStringValue(SqlMiResourceId); + if (Optional.IsDefined(ConnectionTcpPort)) + { + writer.WritePropertyName("connectionTcpPort"u8); + writer.WriteNumberValue(ConnectionTcpPort.Value); + } + if (Optional.IsDefined(ReadIntent)) + { + writer.WritePropertyName("readIntent"u8); + writer.WriteBooleanValue(ReadIntent.Value); + } + } + + SqlMiTargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(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) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier sqlMiResourceId = default; + int? connectionTcpPort = default; + bool? readIntent = default; + string targetType = default; + TargetAuthenticationType targetAuthenticationType = default; + VaultSecret targetVault = default; + string connectionServerName = default; + ResourceProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sqlMiResourceId"u8)) + { + sqlMiResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("connectionTcpPort"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + connectionTcpPort = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("readIntent"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + readIntent = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("targetType"u8)) + { + targetType = property.Value.GetString(); + continue; + } + if (property.NameEquals("targetAuthenticationType"u8)) + { + targetAuthenticationType = new TargetAuthenticationType(property.Value.GetString()); + continue; + } + if (property.NameEquals("targetVault"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetVault = VaultSecret.DeserializeVaultSecret(property.Value, options); + continue; + } + if (property.NameEquals("connectionServerName"u8)) + { + connectionServerName = property.Value.GetString(); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ResourceProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SqlMiTargetProperties( + targetType, + targetAuthenticationType, + targetVault, + connectionServerName, + provisioningState, + serializedAdditionalRawData, + sqlMiResourceId, + connectionTcpPort, + readIntent); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SqlMiTargetProperties)} does not support writing '{options.Format}' format."); + } + } + + SqlMiTargetProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSqlMiTargetProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SqlMiTargetProperties)} does not support reading '{options.Format}' format."); + } + } + + 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 new file mode 100644 index 000000000000..42d4e454cc90 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/SqlMiTargetProperties.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The properties specific to Azure SQL Managed Instance targets. + public partial class SqlMiTargetProperties : TargetProperties + { + /// Initializes a new instance of . + /// 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. + /// 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) + { + Argument.AssertNotNull(connectionServerName, nameof(connectionServerName)); + Argument.AssertNotNull(sqlMiResourceId, nameof(sqlMiResourceId)); + + SqlMiResourceId = sqlMiResourceId; + TargetType = "SqlMi"; + } + + /// Initializes a new instance of . + /// Discriminator property for TargetProperties. + /// 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. + /// 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, VaultSecret targetVault, string connectionServerName, ResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData, ResourceIdentifier sqlMiResourceId, int? connectionTcpPort, bool? readIntent) : base(targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, serializedAdditionalRawData) + { + 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 new file mode 100644 index 000000000000..c75adb8f1d8a --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetAuthenticationType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The type of authentication to use when connecting to a target. + public readonly partial struct TargetAuthenticationType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TargetAuthenticationType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AadValue = "Aad"; + private const string SqlValue = "Sql"; + + /// 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. + public static bool operator ==(TargetAuthenticationType left, TargetAuthenticationType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TargetAuthenticationType left, TargetAuthenticationType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TargetAuthenticationType(string value) => 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/TargetListResult.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetListResult.Serialization.cs new file mode 100644 index 000000000000..2f49056cd2f0 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetListResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + internal partial class TargetListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TargetListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(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) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TargetData.DeserializeTargetData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TargetListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TargetListResult)} does not support writing '{options.Format}' format."); + } + } + + TargetListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTargetListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TargetListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetListResult.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetListResult.cs new file mode 100644 index 000000000000..259a91b4264e --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.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; + + /// 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) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TargetListResult() + { + } + + /// The Target items on this page. + public IReadOnlyList 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/TargetProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetProperties.Serialization.cs new file mode 100644 index 000000000000..339824717aae --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetProperties.Serialization.cs @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + [PersistableModelProxy(typeof(UnknownTargetProperties))] + public partial class TargetProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("targetType"u8); + writer.WriteStringValue(TargetType); + writer.WritePropertyName("targetAuthenticationType"u8); + writer.WriteStringValue(TargetAuthenticationType.ToString()); + if (Optional.IsDefined(TargetVault)) + { + writer.WritePropertyName("targetVault"u8); + writer.WriteObjectValue(TargetVault, options); + } + writer.WritePropertyName("connectionServerName"u8); + writer.WriteStringValue(ConnectionServerName); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTargetProperties(document.RootElement, options); + } + + internal static TargetProperties DeserializeTargetProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("targetType", 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); + } + } + return UnknownTargetProperties.DeserializeUnknownTargetProperties(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TargetProperties)} does not support writing '{options.Format}' format."); + } + } + + TargetProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTargetProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TargetProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetProperties.cs new file mode 100644 index 000000000000..d1adb92b5d4d --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/TargetProperties.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +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 . + /// + public abstract partial class TargetProperties + { + /// + /// 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; + + /// Initializes a new instance of . + /// 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 TargetProperties(TargetAuthenticationType targetAuthenticationType, string connectionServerName) + { + Argument.AssertNotNull(connectionServerName, nameof(connectionServerName)); + + TargetAuthenticationType = targetAuthenticationType; + ConnectionServerName = connectionServerName; + } + + /// Initializes a new instance of . + /// Discriminator property for TargetProperties. + /// 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. + /// Keeps track of any properties unknown to the library. + internal TargetProperties(string targetType, TargetAuthenticationType targetAuthenticationType, VaultSecret targetVault, string connectionServerName, ResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) + { + TargetType = targetType; + TargetAuthenticationType = targetAuthenticationType; + TargetVault = targetVault; + ConnectionServerName = connectionServerName; + ProvisioningState = provisioningState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TargetProperties() + { + } + + /// Discriminator property for TargetProperties. + 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 VaultSecret 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 ResourceProvisioningState? ProvisioningState { get; } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/UnknownTargetProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/UnknownTargetProperties.Serialization.cs new file mode 100644 index 000000000000..8839205ad17b --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/UnknownTargetProperties.Serialization.cs @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + internal partial class UnknownTargetProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetProperties)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + TargetProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTargetProperties(document.RootElement, options); + } + + internal static UnknownTargetProperties DeserializeUnknownTargetProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string targetType = "Unknown"; + TargetAuthenticationType targetAuthenticationType = default; + VaultSecret targetVault = default; + string connectionServerName = default; + ResourceProvisioningState? provisioningState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("targetType"u8)) + { + targetType = property.Value.GetString(); + continue; + } + if (property.NameEquals("targetAuthenticationType"u8)) + { + targetAuthenticationType = new TargetAuthenticationType(property.Value.GetString()); + continue; + } + if (property.NameEquals("targetVault"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetVault = VaultSecret.DeserializeVaultSecret(property.Value, options); + continue; + } + if (property.NameEquals("connectionServerName"u8)) + { + connectionServerName = property.Value.GetString(); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ResourceProvisioningState(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownTargetProperties( + targetType, + targetAuthenticationType, + targetVault, + connectionServerName, + provisioningState, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TargetProperties)} does not support writing '{options.Format}' format."); + } + } + + TargetProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTargetProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TargetProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/UnknownTargetProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/UnknownTargetProperties.cs new file mode 100644 index 000000000000..76b54f72ec12 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/UnknownTargetProperties.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// Unknown version of TargetProperties. + internal partial class UnknownTargetProperties : TargetProperties + { + /// Initializes a new instance of . + /// Discriminator property for TargetProperties. + /// 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. + /// Keeps track of any properties unknown to the library. + internal UnknownTargetProperties(string targetType, TargetAuthenticationType targetAuthenticationType, VaultSecret targetVault, string connectionServerName, ResourceProvisioningState? provisioningState, IDictionary serializedAdditionalRawData) : base(targetType, targetAuthenticationType, targetVault, connectionServerName, provisioningState, serializedAdditionalRawData) + { + TargetType = targetType ?? "Unknown"; + } + + /// Initializes a new instance of for deserialization. + internal UnknownTargetProperties() + { + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ValidationIssue.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ValidationIssue.Serialization.cs new file mode 100644 index 000000000000..310bd65bc1e2 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ValidationIssue.Serialization.cs @@ -0,0 +1,211 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + public partial class ValidationIssue : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ValidationIssue)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("errorCode"u8); + writer.WriteStringValue(ErrorCode); + } + if (options.Format != "W") + { + writer.WritePropertyName("errorMessage"u8); + writer.WriteStringValue(ErrorMessage); + } + if (options.Format != "W" && Optional.IsDefined(AdditionalDetails)) + { + writer.WritePropertyName("additionalDetails"u8); + writer.WriteStringValue(AdditionalDetails); + } + if (options.Format != "W") + { + writer.WritePropertyName("recommendationMessage"u8); + writer.WriteStringValue(RecommendationMessage); + } + if (options.Format != "W" && Optional.IsDefined(RecommendationUri)) + { + writer.WritePropertyName("recommendationUrl"u8); + writer.WriteStringValue(RecommendationUri.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(RelatedResourceId)) + { + writer.WritePropertyName("relatedResourceId"u8); + writer.WriteStringValue(RelatedResourceId); + } + if (options.Format != "W" && Optional.IsDefined(RelatedResourceType)) + { + writer.WritePropertyName("relatedResourceType"u8); + writer.WriteStringValue(RelatedResourceType); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ValidationIssue IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ValidationIssue)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeValidationIssue(document.RootElement, options); + } + + internal static ValidationIssue DeserializeValidationIssue(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string errorCode = default; + string errorMessage = default; + string additionalDetails = default; + string recommendationMessage = default; + Uri recommendationUrl = default; + ResourceIdentifier relatedResourceId = default; + string relatedResourceType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("errorCode"u8)) + { + errorCode = property.Value.GetString(); + continue; + } + if (property.NameEquals("errorMessage"u8)) + { + errorMessage = property.Value.GetString(); + continue; + } + if (property.NameEquals("additionalDetails"u8)) + { + additionalDetails = property.Value.GetString(); + continue; + } + if (property.NameEquals("recommendationMessage"u8)) + { + recommendationMessage = property.Value.GetString(); + continue; + } + if (property.NameEquals("recommendationUrl"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recommendationUrl = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("relatedResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + relatedResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("relatedResourceType"u8)) + { + relatedResourceType = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ValidationIssue( + errorCode, + errorMessage, + additionalDetails, + recommendationMessage, + recommendationUrl, + relatedResourceId, + relatedResourceType, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ValidationIssue)} does not support writing '{options.Format}' format."); + } + } + + ValidationIssue IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeValidationIssue(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ValidationIssue)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ValidationIssue.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ValidationIssue.cs new file mode 100644 index 000000000000..5cf33b03fc68 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ValidationIssue.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The model of a health validation issue. + public partial class ValidationIssue + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The error code of the issue. + /// The error message of the issue. + /// The recommendation for resolving the issue. + internal ValidationIssue(string errorCode, string errorMessage, string recommendationMessage) + { + ErrorCode = errorCode; + ErrorMessage = errorMessage; + RecommendationMessage = recommendationMessage; + } + + /// Initializes a new instance of . + /// The error code of the issue. + /// The error message of the issue. + /// The additional details for the issue. + /// The recommendation for resolving the issue. + /// 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 ValidationIssue(string errorCode, string errorMessage, string additionalDetails, string recommendationMessage, Uri recommendationUri, ResourceIdentifier relatedResourceId, string relatedResourceType, IDictionary serializedAdditionalRawData) + { + ErrorCode = errorCode; + ErrorMessage = errorMessage; + AdditionalDetails = additionalDetails; + RecommendationMessage = recommendationMessage; + RecommendationUri = recommendationUri; + RelatedResourceId = relatedResourceId; + RelatedResourceType = relatedResourceType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ValidationIssue() + { + } + + /// 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 string RelatedResourceType { get; } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ValidationStatus.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ValidationStatus.cs new file mode 100644 index 000000000000..91cdfb16fa7a --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/ValidationStatus.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// Health validation status. + public readonly partial struct ValidationStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ValidationStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NotStartedValue = "NotStarted"; + private const string RunningValue = "Running"; + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + private const string TimedOutValue = "TimedOut"; + + /// Health validation has not started. + public static ValidationStatus NotStarted { get; } = new ValidationStatus(NotStartedValue); + /// Health validation is running. + public static ValidationStatus Running { get; } = new ValidationStatus(RunningValue); + /// Health validation completed successfully. + public static ValidationStatus Succeeded { get; } = new ValidationStatus(SucceededValue); + /// Health validation failed. + public static ValidationStatus Failed { get; } = new ValidationStatus(FailedValue); + /// Health validation was canceled. + public static ValidationStatus Canceled { get; } = new ValidationStatus(CanceledValue); + /// Health validation timed out. + public static ValidationStatus TimedOut { get; } = new ValidationStatus(TimedOutValue); + /// Determines if two values are the same. + public static bool operator ==(ValidationStatus left, ValidationStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ValidationStatus left, ValidationStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ValidationStatus(string value) => new ValidationStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ValidationStatus other && Equals(other); + /// + public bool Equals(ValidationStatus 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/VaultSecret.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/VaultSecret.Serialization.cs new file mode 100644 index 000000000000..fb1f3c4357b8 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/VaultSecret.Serialization.cs @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + public partial class VaultSecret : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VaultSecret)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(AkvResourceId)) + { + writer.WritePropertyName("akvResourceId"u8); + writer.WriteStringValue(AkvResourceId); + } + if (Optional.IsDefined(AkvTargetUser)) + { + writer.WritePropertyName("akvTargetUser"u8); + writer.WriteStringValue(AkvTargetUser); + } + if (Optional.IsDefined(AkvTargetPassword)) + { + writer.WritePropertyName("akvTargetPassword"u8); + writer.WriteStringValue(AkvTargetPassword); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VaultSecret IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VaultSecret)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVaultSecret(document.RootElement, options); + } + + internal static VaultSecret DeserializeVaultSecret(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier akvResourceId = default; + string akvTargetUser = default; + string akvTargetPassword = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("akvResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + akvResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("akvTargetUser"u8)) + { + akvTargetUser = property.Value.GetString(); + continue; + } + if (property.NameEquals("akvTargetPassword"u8)) + { + akvTargetPassword = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VaultSecret(akvResourceId, akvTargetUser, akvTargetPassword, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VaultSecret)} does not support writing '{options.Format}' format."); + } + } + + VaultSecret IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVaultSecret(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VaultSecret)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/VaultSecret.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/VaultSecret.cs new file mode 100644 index 000000000000..0a2c32493558 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/VaultSecret.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The vault specific details required if using SQL authentication to connect to a target. + public partial class VaultSecret + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public VaultSecret() + { + } + + /// Initializes a new instance of . + /// 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 VaultSecret(ResourceIdentifier akvResourceId, string akvTargetUser, string akvTargetPassword, IDictionary serializedAdditionalRawData) + { + AkvResourceId = akvResourceId; + AkvTargetUser = akvTargetUser; + AkvTargetPassword = akvTargetPassword; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// 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/WatcherListResult.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherListResult.Serialization.cs new file mode 100644 index 000000000000..de252e1abb9e --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherListResult.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + internal partial class WatcherListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WatcherListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WatcherListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(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) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(WatcherData.DeserializeWatcherData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WatcherListResult(value, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(WatcherListResult)} does not support writing '{options.Format}' format."); + } + } + + WatcherListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeWatcherListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WatcherListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherListResult.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherListResult.cs new file mode 100644 index 000000000000..13fbd3c33992 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherListResult.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.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; + + /// 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) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal WatcherListResult() + { + } + + /// The Watcher items on this page. + public IReadOnlyList 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/WatcherPatch.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherPatch.Serialization.cs new file mode 100644 index 000000000000..700a3eb45267 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherPatch.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + public partial class WatcherPatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WatcherPatch)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + writer.WriteObjectValue(Identity, options); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WatcherPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WatcherPatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWatcherPatch(document.RootElement, options); + } + + internal static WatcherPatch DeserializeWatcherPatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ManagedServiceIdentityV4 identity = default; + IDictionary tags = default; + WatcherUpdateProperties properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = ManagedServiceIdentityV4.DeserializeManagedServiceIdentityV4(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = WatcherUpdateProperties.DeserializeWatcherUpdateProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WatcherPatch(identity, tags ?? new ChangeTrackingDictionary(), properties, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(WatcherPatch)} does not support writing '{options.Format}' format."); + } + } + + WatcherPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeWatcherPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WatcherPatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherPatch.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherPatch.cs new file mode 100644 index 000000000000..59324b3e1f44 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherPatch.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The type used for update operations of the Watcher. + public partial class WatcherPatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public WatcherPatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// 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 WatcherPatch(ManagedServiceIdentityV4 identity, IDictionary tags, WatcherUpdateProperties properties, IDictionary serializedAdditionalRawData) + { + Identity = identity; + Tags = tags; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The managed service identities assigned to this resource. + public ManagedServiceIdentityV4 Identity { get; set; } + /// Resource tags. + public IDictionary Tags { get; } + /// The resource-specific properties for this resource. + public WatcherUpdateProperties Properties { get; set; } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherProperties.Serialization.cs new file mode 100644 index 000000000000..4ab4881f4833 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherProperties.Serialization.cs @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + public partial class WatcherProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WatcherProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Datastore)) + { + writer.WritePropertyName("datastore"u8); + writer.WriteObjectValue(Datastore, options); + } + if (options.Format != "W" && Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(DefaultAlertRuleIdentityResourceId)) + { + writer.WritePropertyName("defaultAlertRuleIdentityResourceId"u8); + writer.WriteStringValue(DefaultAlertRuleIdentityResourceId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WatcherProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WatcherProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWatcherProperties(document.RootElement, options); + } + + internal static WatcherProperties DeserializeWatcherProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Datastore datastore = default; + WatcherStatus? status = default; + DatabaseWatcherProvisioningState? provisioningState = default; + ResourceIdentifier defaultAlertRuleIdentityResourceId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("datastore"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + datastore = Datastore.DeserializeDatastore(property.Value, options); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new WatcherStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new DatabaseWatcherProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("defaultAlertRuleIdentityResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + defaultAlertRuleIdentityResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WatcherProperties(datastore, status, provisioningState, defaultAlertRuleIdentityResourceId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(WatcherProperties)} does not support writing '{options.Format}' format."); + } + } + + WatcherProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeWatcherProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WatcherProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherProperties.cs new file mode 100644 index 000000000000..1d6b63a67ef7 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherProperties.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 Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The RP specific properties of the resource. + public partial class WatcherProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public WatcherProperties() + { + } + + /// Initializes a new instance of . + /// 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. + /// Keeps track of any properties unknown to the library. + internal WatcherProperties(Datastore datastore, WatcherStatus? status, DatabaseWatcherProvisioningState? provisioningState, ResourceIdentifier defaultAlertRuleIdentityResourceId, IDictionary serializedAdditionalRawData) + { + Datastore = datastore; + Status = status; + ProvisioningState = provisioningState; + DefaultAlertRuleIdentityResourceId = defaultAlertRuleIdentityResourceId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The data store for collected monitoring data. + public Datastore Datastore { get; set; } + /// The monitoring collection status of the watcher. + public WatcherStatus? 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/WatcherStatus.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherStatus.cs new file mode 100644 index 000000000000..302a581fe79e --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherStatus.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The monitoring collection status of a watcher. + public readonly partial struct WatcherStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public WatcherStatus(string value) + { + _value = value ?? throw new ArgumentNullException(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"; + + /// Denotes the watcher is in a starting state. + public static WatcherStatus Starting { get; } = new WatcherStatus(StartingValue); + /// Denotes the watcher is in a running state. + public static WatcherStatus Running { get; } = new WatcherStatus(RunningValue); + /// Denotes the watcher is in a stopping state. + public static WatcherStatus Stopping { get; } = new WatcherStatus(StoppingValue); + /// Denotes the watcher is in a stopped state. + public static WatcherStatus Stopped { get; } = new WatcherStatus(StoppedValue); + /// Denotes the watcher is in a deleting state. + public static WatcherStatus Deleting { get; } = new WatcherStatus(DeletingValue); + /// Determines if two values are the same. + public static bool operator ==(WatcherStatus left, WatcherStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(WatcherStatus left, WatcherStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator WatcherStatus(string value) => new WatcherStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is WatcherStatus other && Equals(other); + /// + public bool Equals(WatcherStatus 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/WatcherUpdateProperties.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherUpdateProperties.Serialization.cs new file mode 100644 index 000000000000..02dbddbb9cdd --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherUpdateProperties.Serialization.cs @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + public partial class WatcherUpdateProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WatcherUpdateProperties)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Datastore)) + { + writer.WritePropertyName("datastore"u8); + writer.WriteObjectValue(Datastore, options); + } + if (Optional.IsDefined(DefaultAlertRuleIdentityResourceId)) + { + writer.WritePropertyName("defaultAlertRuleIdentityResourceId"u8); + writer.WriteStringValue(DefaultAlertRuleIdentityResourceId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WatcherUpdateProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WatcherUpdateProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWatcherUpdateProperties(document.RootElement, options); + } + + internal static WatcherUpdateProperties DeserializeWatcherUpdateProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Datastore datastore = default; + ResourceIdentifier defaultAlertRuleIdentityResourceId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("datastore"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + datastore = Datastore.DeserializeDatastore(property.Value, options); + continue; + } + if (property.NameEquals("defaultAlertRuleIdentityResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + defaultAlertRuleIdentityResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WatcherUpdateProperties(datastore, defaultAlertRuleIdentityResourceId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(WatcherUpdateProperties)} does not support writing '{options.Format}' format."); + } + } + + WatcherUpdateProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeWatcherUpdateProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WatcherUpdateProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherUpdateProperties.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherUpdateProperties.cs new file mode 100644 index 000000000000..efbe98de6d9e --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/Models/WatcherUpdateProperties.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.DatabaseWatcher.Models +{ + /// The updatable properties of the Watcher. + public partial class WatcherUpdateProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public WatcherUpdateProperties() + { + } + + /// 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 WatcherUpdateProperties(Datastore datastore, ResourceIdentifier defaultAlertRuleIdentityResourceId, IDictionary serializedAdditionalRawData) + { + Datastore = datastore; + DefaultAlertRuleIdentityResourceId = defaultAlertRuleIdentityResourceId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The data store for collected monitoring data. + public Datastore 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/ProviderConstants.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..4bbac7bcb68c --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/ProviderConstants.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal static class ProviderConstants + { + 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 new file mode 100644 index 000000000000..2c9fb5ca2e7f --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/AlertRuleResourcesRestOperations.cs @@ -0,0 +1,523 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class AlertRuleResourcesRestOperations + { + 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) + { + 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) + { + 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: + { + AlertRuleResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AlertRuleResourceData.DeserializeAlertRuleResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((AlertRuleResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// 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)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, watcherName, alertRuleResourceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + AlertRuleResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AlertRuleResourceData.DeserializeAlertRuleResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((AlertRuleResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName, AlertRuleResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.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 CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string watcherName, string alertRuleResourceName, AlertRuleResourceData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.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"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a 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, AlertRuleResourceData 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: + { + AlertRuleResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = AlertRuleResourceData.DeserializeAlertRuleResourceData(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, AlertRuleResourceData 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); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + AlertRuleResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = AlertRuleResourceData.DeserializeAlertRuleResourceData(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(); + 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("/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; + } + + /// 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) + { + 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.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("/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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + 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) + { + 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, default, 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); + 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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + 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, default, 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); + 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 new file mode 100644 index 000000000000..37df4a8b8142 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/HealthValidationsRestOperations.cs @@ -0,0 +1,415 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class HealthValidationsRestOperations + { + 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) + { + _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) + { + 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; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string watcherName, string healthValidationName) + { + 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("/healthValidations/", false); + uri.AppendPath(healthValidationName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + 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) + { + 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: + { + HealthValidationData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = HealthValidationData.DeserializeHealthValidationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((HealthValidationData)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: + { + HealthValidationData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = HealthValidationData.DeserializeHealthValidationData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((HealthValidationData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByParentRequestUri(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("/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("/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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + 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, default, 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); + 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) + { + 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; + } + + internal HttpMessage CreateStartValidationRequest(string subscriptionId, string resourceGroupName, string watcherName, string healthValidationName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + 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); + 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); + 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, default, 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); + 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 new file mode 100644 index 000000000000..3ab54b61518a --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/SharedPrivateLinkResourcesRestOperations.cs @@ -0,0 +1,513 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class SharedPrivateLinkResourcesRestOperations + { + 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) + { + 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) + { + 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: + { + SharedPrivateLinkResourceData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = SharedPrivateLinkResourceData.DeserializeSharedPrivateLinkResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((SharedPrivateLinkResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// 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)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, watcherName, sharedPrivateLinkResourceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + SharedPrivateLinkResourceData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = SharedPrivateLinkResourceData.DeserializeSharedPrivateLinkResourceData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((SharedPrivateLinkResourceData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateRequestUri(string subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName, SharedPrivateLinkResourceData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.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 CreateCreateRequest(string subscriptionId, string resourceGroupName, string watcherName, string sharedPrivateLinkResourceName, SharedPrivateLinkResourceData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.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"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a 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, SharedPrivateLinkResourceData 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, SharedPrivateLinkResourceData 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); + _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(); + 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("/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; + } + + /// 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) + { + 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.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("/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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + 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) + { + 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, default, 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); + 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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + 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, default, 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); + 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 new file mode 100644 index 000000000000..373a87db6065 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/TargetsRestOperations.cs @@ -0,0 +1,523 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class TargetsRestOperations + { + 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) + { + 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) + { + 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: + { + TargetData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = TargetData.DeserializeTargetData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((TargetData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// 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)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, watcherName, targetName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + TargetData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = TargetData.DeserializeTargetData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((TargetData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string watcherName, string targetName, TargetData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.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 CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string watcherName, string targetName, TargetData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.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"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a 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, TargetData 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: + { + TargetData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = TargetData.DeserializeTargetData(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, TargetData 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); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + { + TargetData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = TargetData.DeserializeTargetData(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(); + 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("/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; + } + + /// 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) + { + 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.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("/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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + 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) + { + 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, default, 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); + 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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + 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, default, 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); + 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 new file mode 100644 index 000000000000..5d32fbe3a59d --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/RestOperations/WatchersRestOperations.cs @@ -0,0 +1,895 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + internal partial class WatchersRestOperations + { + 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) + { + _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) + { + 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: + { + WatcherData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = WatcherData.DeserializeWatcherData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((WatcherData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// 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)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, watcherName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + WatcherData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = WatcherData.DeserializeWatcherData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((WatcherData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string watcherName, WatcherData data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); + uri.AppendPath(watcherName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string watcherName, WatcherData data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); + uri.AppendPath(watcherName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a 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, WatcherData 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, WatcherData 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); + _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, WatcherPatch patch) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers/", false); + uri.AppendPath(watcherName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string watcherName, WatcherPatch 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("/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"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + 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, WatcherPatch 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, WatcherPatch 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); + _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(); + 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("/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; + } + + /// 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) + { + 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(); + 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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + 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, default, 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) + { + 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); + 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; + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.DatabaseWatcher/watchers", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + 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) + { + 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, default, 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); + 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; + } + + internal HttpMessage CreateStartRequest(string subscriptionId, string resourceGroupName, string watcherName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + 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); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + 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) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + 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); + 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, default, 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); + 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); + 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, default, 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); + 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/SharedPrivateLinkResource.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResource.Serialization.cs new file mode 100644 index 000000000000..f50fbe916eab --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + public partial class SharedPrivateLinkResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + SharedPrivateLinkResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + SharedPrivateLinkResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResource.cs new file mode 100644 index 000000000000..9a49a30dacff --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResource.cs @@ -0,0 +1,347 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A Class representing a SharedPrivateLinkResource 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 GetSharedPrivateLinkResource method. + /// Otherwise you can get one from its parent resource using the GetSharedPrivateLinkResource method. + /// + public partial class SharedPrivateLinkResource : 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 _sharedPrivateLinkResourceClientDiagnostics; + private readonly SharedPrivateLinkResourcesRestOperations _sharedPrivateLinkResourceRestClient; + private readonly SharedPrivateLinkResourceData _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. + protected SharedPrivateLinkResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal SharedPrivateLinkResource(ArmClient client, SharedPrivateLinkResourceData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal SharedPrivateLinkResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _sharedPrivateLinkResourceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string sharedPrivateLinkResourceApiVersion); + _sharedPrivateLinkResourceRestClient = new SharedPrivateLinkResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, sharedPrivateLinkResourceApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 SharedPrivateLinkResourceData 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)); + } + + /// + /// 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 cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _sharedPrivateLinkResourceClientDiagnostics.CreateScope("SharedPrivateLinkResource.Get"); + scope.Start(); + try + { + var response = await _sharedPrivateLinkResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SharedPrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _sharedPrivateLinkResourceClientDiagnostics.CreateScope("SharedPrivateLinkResource.Get"); + scope.Start(); + try + { + var response = _sharedPrivateLinkResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SharedPrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a SharedPrivateLinkResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// + /// + /// Operation Id + /// SharedPrivateLinkResource_Delete + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _sharedPrivateLinkResourceClientDiagnostics.CreateScope("SharedPrivateLinkResource.Delete"); + scope.Start(); + try + { + var response = await _sharedPrivateLinkResourceRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new DatabaseWatcherArmOperation(_sharedPrivateLinkResourceClientDiagnostics, Pipeline, _sharedPrivateLinkResourceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a SharedPrivateLinkResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// + /// + /// Operation Id + /// SharedPrivateLinkResource_Delete + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _sharedPrivateLinkResourceClientDiagnostics.CreateScope("SharedPrivateLinkResource.Delete"); + scope.Start(); + try + { + var response = _sharedPrivateLinkResourceRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new DatabaseWatcherArmOperation(_sharedPrivateLinkResourceClientDiagnostics, Pipeline, _sharedPrivateLinkResourceRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a SharedPrivateLinkResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// + /// + /// Operation Id + /// SharedPrivateLinkResource_Create + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, SharedPrivateLinkResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _sharedPrivateLinkResourceClientDiagnostics.CreateScope("SharedPrivateLinkResource.Update"); + scope.Start(); + try + { + var response = await _sharedPrivateLinkResourceRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new DatabaseWatcherArmOperation(new SharedPrivateLinkResourceOperationSource(Client), _sharedPrivateLinkResourceClientDiagnostics, Pipeline, _sharedPrivateLinkResourceRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a SharedPrivateLinkResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// + /// + /// Operation Id + /// SharedPrivateLinkResource_Create + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, SharedPrivateLinkResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _sharedPrivateLinkResourceClientDiagnostics.CreateScope("SharedPrivateLinkResource.Update"); + scope.Start(); + try + { + var response = _sharedPrivateLinkResourceRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new DatabaseWatcherArmOperation(new SharedPrivateLinkResourceOperationSource(Client), _sharedPrivateLinkResourceClientDiagnostics, Pipeline, _sharedPrivateLinkResourceRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourceCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourceCollection.cs new file mode 100644 index 000000000000..381ddc746320 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourceCollection.cs @@ -0,0 +1,493 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetSharedPrivateLinkResources method from an instance of . + /// + public partial class SharedPrivateLinkResourceCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _sharedPrivateLinkResourceClientDiagnostics; + private readonly SharedPrivateLinkResourcesRestOperations _sharedPrivateLinkResourceRestClient; + + /// Initializes a new instance of the class for mocking. + protected SharedPrivateLinkResourceCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal SharedPrivateLinkResourceCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _sharedPrivateLinkResourceClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", SharedPrivateLinkResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(SharedPrivateLinkResource.ResourceType, out string sharedPrivateLinkResourceApiVersion); + _sharedPrivateLinkResourceRestClient = new SharedPrivateLinkResourcesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, sharedPrivateLinkResourceApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != WatcherResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, WatcherResource.ResourceType), nameof(id)); + } + + /// + /// Create a SharedPrivateLinkResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// + /// + /// Operation Id + /// SharedPrivateLinkResource_Create + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 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. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string sharedPrivateLinkResourceName, SharedPrivateLinkResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _sharedPrivateLinkResourceClientDiagnostics.CreateScope("SharedPrivateLinkResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _sharedPrivateLinkResourceRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, data, cancellationToken).ConfigureAwait(false); + var operation = new DatabaseWatcherArmOperation(new SharedPrivateLinkResourceOperationSource(Client), _sharedPrivateLinkResourceClientDiagnostics, Pipeline, _sharedPrivateLinkResourceRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a SharedPrivateLinkResource + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName} + /// + /// + /// Operation Id + /// SharedPrivateLinkResource_Create + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 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. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string sharedPrivateLinkResourceName, SharedPrivateLinkResourceData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _sharedPrivateLinkResourceClientDiagnostics.CreateScope("SharedPrivateLinkResourceCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _sharedPrivateLinkResourceRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, data, cancellationToken); + var operation = new DatabaseWatcherArmOperation(new SharedPrivateLinkResourceOperationSource(Client), _sharedPrivateLinkResourceClientDiagnostics, Pipeline, _sharedPrivateLinkResourceRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); + + using var scope = _sharedPrivateLinkResourceClientDiagnostics.CreateScope("SharedPrivateLinkResourceCollection.Get"); + scope.Start(); + try + { + var response = await _sharedPrivateLinkResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SharedPrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); + + using var scope = _sharedPrivateLinkResourceClientDiagnostics.CreateScope("SharedPrivateLinkResourceCollection.Get"); + scope.Start(); + try + { + var response = _sharedPrivateLinkResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new SharedPrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List SharedPrivateLinkResource resources by Watcher + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources + /// + /// + /// Operation Id + /// SharedPrivateLinkResource_ListByWatcher + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _sharedPrivateLinkResourceRestClient.CreateListByWatcherRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _sharedPrivateLinkResourceRestClient.CreateListByWatcherNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new SharedPrivateLinkResource(Client, SharedPrivateLinkResourceData.DeserializeSharedPrivateLinkResourceData(e)), _sharedPrivateLinkResourceClientDiagnostics, Pipeline, "SharedPrivateLinkResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List SharedPrivateLinkResource resources by Watcher + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/sharedPrivateLinkResources + /// + /// + /// Operation Id + /// SharedPrivateLinkResource_ListByWatcher + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _sharedPrivateLinkResourceRestClient.CreateListByWatcherRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _sharedPrivateLinkResourceRestClient.CreateListByWatcherNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new SharedPrivateLinkResource(Client, SharedPrivateLinkResourceData.DeserializeSharedPrivateLinkResourceData(e)), _sharedPrivateLinkResourceClientDiagnostics, Pipeline, "SharedPrivateLinkResourceCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); + + using var scope = _sharedPrivateLinkResourceClientDiagnostics.CreateScope("SharedPrivateLinkResourceCollection.Exists"); + scope.Start(); + try + { + var response = await _sharedPrivateLinkResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); + + using var scope = _sharedPrivateLinkResourceClientDiagnostics.CreateScope("SharedPrivateLinkResourceCollection.Exists"); + scope.Start(); + try + { + var response = _sharedPrivateLinkResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); + + using var scope = _sharedPrivateLinkResourceClientDiagnostics.CreateScope("SharedPrivateLinkResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _sharedPrivateLinkResourceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new SharedPrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(sharedPrivateLinkResourceName, nameof(sharedPrivateLinkResourceName)); + + using var scope = _sharedPrivateLinkResourceClientDiagnostics.CreateScope("SharedPrivateLinkResourceCollection.GetIfExists"); + scope.Start(); + try + { + var response = _sharedPrivateLinkResourceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, sharedPrivateLinkResourceName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new SharedPrivateLinkResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourceData.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourceData.Serialization.cs new file mode 100644 index 000000000000..00e69ad597b8 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourceData.Serialization.cs @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + public partial class SharedPrivateLinkResourceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharedPrivateLinkResourceData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + SharedPrivateLinkResourceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharedPrivateLinkResourceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSharedPrivateLinkResourceData(document.RootElement, options); + } + + internal static SharedPrivateLinkResourceData DeserializeSharedPrivateLinkResourceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SharedPrivateLinkResourceProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = SharedPrivateLinkResourceProperties.DeserializeSharedPrivateLinkResourceProperties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SharedPrivateLinkResourceData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SharedPrivateLinkResourceData)} does not support writing '{options.Format}' format."); + } + } + + SharedPrivateLinkResourceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSharedPrivateLinkResourceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SharedPrivateLinkResourceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourceData.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourceData.cs new file mode 100644 index 000000000000..45f2b1b41d87 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/SharedPrivateLinkResourceData.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A class representing the SharedPrivateLinkResource data model. + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + /// + public partial class SharedPrivateLinkResourceData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public SharedPrivateLinkResourceData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal SharedPrivateLinkResourceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, SharedPrivateLinkResourceProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The resource-specific properties for this resource. + public SharedPrivateLinkResourceProperties Properties { get; set; } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetCollection.cs new file mode 100644 index 000000000000..4dbbaeab8572 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetCollection.cs @@ -0,0 +1,497 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetTargets method from an instance of . + /// + public partial class TargetCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _targetClientDiagnostics; + private readonly TargetsRestOperations _targetRestClient; + + /// Initializes a new instance of the class for mocking. + protected TargetCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal TargetCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _targetClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", TargetResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(TargetResource.ResourceType, out string targetApiVersion); + _targetRestClient = new TargetsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, targetApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != WatcherResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, WatcherResource.ResourceType), nameof(id)); + } + + /// + /// Create a Target + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// + /// + /// Operation Id + /// Target_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 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. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string targetName, TargetData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _targetClientDiagnostics.CreateScope("TargetCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _targetRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, data, cancellationToken).ConfigureAwait(false); + var uri = _targetRestClient.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 TargetResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a Target + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// + /// + /// Operation Id + /// Target_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 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. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string targetName, TargetData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _targetClientDiagnostics.CreateScope("TargetCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _targetRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, data, cancellationToken); + var uri = _targetRestClient.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 TargetResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string targetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); + + using var scope = _targetClientDiagnostics.CreateScope("TargetCollection.Get"); + scope.Start(); + try + { + var response = await _targetRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TargetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string targetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); + + using var scope = _targetClientDiagnostics.CreateScope("TargetCollection.Get"); + scope.Start(); + try + { + var response = _targetRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TargetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Target resources by Watcher + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets + /// + /// + /// Operation Id + /// Target_ListByWatcher + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _targetRestClient.CreateListByWatcherRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _targetRestClient.CreateListByWatcherNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new TargetResource(Client, TargetData.DeserializeTargetData(e)), _targetClientDiagnostics, Pipeline, "TargetCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List Target resources by Watcher + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets + /// + /// + /// Operation Id + /// Target_ListByWatcher + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _targetRestClient.CreateListByWatcherRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _targetRestClient.CreateListByWatcherNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new TargetResource(Client, TargetData.DeserializeTargetData(e)), _targetClientDiagnostics, Pipeline, "TargetCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string targetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); + + using var scope = _targetClientDiagnostics.CreateScope("TargetCollection.Exists"); + scope.Start(); + try + { + var response = await _targetRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string targetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); + + using var scope = _targetClientDiagnostics.CreateScope("TargetCollection.Exists"); + scope.Start(); + try + { + var response = _targetRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string targetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); + + using var scope = _targetClientDiagnostics.CreateScope("TargetCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _targetRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new TargetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// 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 an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string targetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(targetName, nameof(targetName)); + + using var scope = _targetClientDiagnostics.CreateScope("TargetCollection.GetIfExists"); + scope.Start(); + try + { + var response = _targetRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, targetName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new TargetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetData.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetData.Serialization.cs new file mode 100644 index 000000000000..516a1a20c363 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetData.Serialization.cs @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + public partial class TargetData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + TargetData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTargetData(document.RootElement, options); + } + + internal static TargetData DeserializeTargetData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TargetProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = TargetProperties.DeserializeTargetProperties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TargetData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TargetData)} does not support writing '{options.Format}' format."); + } + } + + TargetData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTargetData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TargetData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetData.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetData.cs new file mode 100644 index 000000000000..04dda036ff16 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetData.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A class representing the Target data model. + /// Concrete proxy resource types can be created by aliasing this type using a specific property type. + /// + public partial class TargetData : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TargetData() + { + } + + /// 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 TargetData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, TargetProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + 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 . + /// + public TargetProperties Properties { get; set; } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetResource.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetResource.Serialization.cs new file mode 100644 index 000000000000..64a7c916ca21 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + public partial class TargetResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + TargetData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + TargetData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetResource.cs new file mode 100644 index 000000000000..654e6c42cde4 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/TargetResource.cs @@ -0,0 +1,355 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A Class representing a Target 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 GetTargetResource method. + /// Otherwise you can get one from its parent resource using the GetTarget method. + /// + public partial class TargetResource : 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 _targetClientDiagnostics; + private readonly TargetsRestOperations _targetRestClient; + private readonly TargetData _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. + protected TargetResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal TargetResource(ArmClient client, TargetData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal TargetResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _targetClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string targetApiVersion); + _targetRestClient = new TargetsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, targetApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 TargetData 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)); + } + + /// + /// 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 cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _targetClientDiagnostics.CreateScope("TargetResource.Get"); + scope.Start(); + try + { + var response = await _targetRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TargetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _targetClientDiagnostics.CreateScope("TargetResource.Get"); + scope.Start(); + try + { + var response = _targetRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new TargetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Target + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// + /// + /// Operation Id + /// Target_Delete + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _targetClientDiagnostics.CreateScope("TargetResource.Delete"); + scope.Start(); + try + { + var response = await _targetRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _targetRestClient.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); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Target + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// + /// + /// Operation Id + /// Target_Delete + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _targetClientDiagnostics.CreateScope("TargetResource.Delete"); + scope.Start(); + try + { + var response = _targetRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var uri = _targetRestClient.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); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a Target + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// + /// + /// Operation Id + /// Target_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, TargetData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _targetClientDiagnostics.CreateScope("TargetResource.Update"); + scope.Start(); + try + { + var response = await _targetRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var uri = _targetRestClient.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 TargetResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a Target + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/targets/{targetName} + /// + /// + /// Operation Id + /// Target_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, TargetData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _targetClientDiagnostics.CreateScope("TargetResource.Update"); + scope.Start(); + try + { + var response = _targetRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var uri = _targetRestClient.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 TargetResource(Client, response), response.GetRawResponse()), rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherCollection.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherCollection.cs new file mode 100644 index 000000000000..4ec24987d6d6 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherCollection.cs @@ -0,0 +1,494 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetWatchers method from an instance of . + /// + public partial class WatcherCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _watcherClientDiagnostics; + private readonly WatchersRestOperations _watcherRestClient; + + /// Initializes a new instance of the class for mocking. + protected WatcherCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal WatcherCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _watcherClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", WatcherResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(WatcherResource.ResourceType, out string watcherApiVersion); + _watcherRestClient = new WatchersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, watcherApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + 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)); + } + + /// + /// Create a Watcher + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// + /// + /// Operation Id + /// Watcher_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 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. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string watcherName, WatcherData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _watcherRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, watcherName, data, cancellationToken).ConfigureAwait(false); + var operation = new DatabaseWatcherArmOperation(new WatcherOperationSource(Client), _watcherClientDiagnostics, Pipeline, _watcherRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, watcherName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a Watcher + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// + /// + /// Operation Id + /// Watcher_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 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. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string watcherName, WatcherData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _watcherRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, watcherName, data, cancellationToken); + var operation = new DatabaseWatcherArmOperation(new WatcherOperationSource(Client), _watcherClientDiagnostics, Pipeline, _watcherRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, watcherName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 + /// + /// + /// + /// + /// The database watcher name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string watcherName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherCollection.Get"); + scope.Start(); + try + { + var response = await _watcherRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, watcherName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new WatcherResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 + /// + /// + /// + /// + /// The database watcher name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string watcherName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherCollection.Get"); + scope.Start(); + try + { + var response = _watcherRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, watcherName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new WatcherResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Watcher resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers + /// + /// + /// Operation Id + /// Watcher_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _watcherRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _watcherRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new WatcherResource(Client, WatcherData.DeserializeWatcherData(e)), _watcherClientDiagnostics, Pipeline, "WatcherCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List Watcher resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers + /// + /// + /// Operation Id + /// Watcher_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _watcherRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _watcherRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new WatcherResource(Client, WatcherData.DeserializeWatcherData(e)), _watcherClientDiagnostics, Pipeline, "WatcherCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// + /// + /// Operation Id + /// Watcher_Get + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// Resource + /// + /// + /// + /// + /// The database watcher name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string watcherName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherCollection.Exists"); + scope.Start(); + try + { + var response = await _watcherRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, watcherName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// + /// + /// Operation Id + /// Watcher_Get + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// Resource + /// + /// + /// + /// + /// The database watcher name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string watcherName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherCollection.Exists"); + scope.Start(); + try + { + var response = _watcherRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, watcherName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// + /// + /// Operation Id + /// Watcher_Get + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// Resource + /// + /// + /// + /// + /// The database watcher name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string watcherName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _watcherRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, watcherName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new WatcherResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// + /// + /// Operation Id + /// Watcher_Get + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// Resource + /// + /// + /// + /// + /// The database watcher name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string watcherName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(watcherName, nameof(watcherName)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherCollection.GetIfExists"); + scope.Start(); + try + { + var response = _watcherRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, watcherName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new WatcherResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherData.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherData.Serialization.cs new file mode 100644 index 000000000000..132d2e09dc8c --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherData.Serialization.cs @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + public partial class WatcherData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WatcherData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + writer.WriteObjectValue(Identity, options); + } + } + + WatcherData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WatcherData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWatcherData(document.RootElement, options); + } + + internal static WatcherData DeserializeWatcherData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WatcherProperties properties = default; + ManagedServiceIdentityV4 identity = default; + IDictionary tags = default; + AzureLocation location = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = WatcherProperties.DeserializeWatcherProperties(property.Value, options); + continue; + } + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = ManagedServiceIdentityV4.DeserializeManagedServiceIdentityV4(property.Value, options); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WatcherData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + identity, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(WatcherData)} does not support writing '{options.Format}' format."); + } + } + + WatcherData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeWatcherData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WatcherData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherData.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherData.cs new file mode 100644 index 000000000000..db4ed0ffd517 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherData.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.DatabaseWatcher.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A class representing the Watcher data model. + /// The DatabaseWatcherProviderHub resource. + /// + public partial class WatcherData : 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; + + /// Initializes a new instance of . + /// The location. + public WatcherData(AzureLocation location) : base(location) + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// 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 WatcherData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, WatcherProperties properties, ManagedServiceIdentityV4 identity, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + Properties = properties; + Identity = identity; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal WatcherData() + { + } + + /// The resource-specific properties for this resource. + public WatcherProperties Properties { get; set; } + /// The managed service identities assigned to this resource. + public ManagedServiceIdentityV4 Identity { get; set; } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherResource.Serialization.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherResource.Serialization.cs new file mode 100644 index 000000000000..3d31f027fcdd --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + public partial class WatcherResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + WatcherData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + WatcherData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherResource.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherResource.cs new file mode 100644 index 000000000000..7b83019f45da --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Generated/WatcherResource.cs @@ -0,0 +1,1151 @@ +// 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.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.DatabaseWatcher.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.DatabaseWatcher +{ + /// + /// A Class representing a Watcher 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 GetWatcherResource method. + /// Otherwise you can get one from its parent resource using the GetWatcher method. + /// + public partial class WatcherResource : 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 _watcherClientDiagnostics; + private readonly WatchersRestOperations _watcherRestClient; + private readonly WatcherData _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. + protected WatcherResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal WatcherResource(ArmClient client, WatcherData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal WatcherResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _watcherClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.DatabaseWatcher", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string watcherApiVersion); + _watcherRestClient = new WatchersRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, watcherApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 WatcherData 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 AlertRuleResources in the Watcher. + /// An object representing collection of AlertRuleResources and their operations over a AlertRuleResource. + public virtual AlertRuleResourceCollection GetAlertRuleResources() + { + return GetCachedClient(client => new AlertRuleResourceCollection(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> GetAlertRuleResourceAsync(string alertRuleResourceName, CancellationToken cancellationToken = default) + { + return await GetAlertRuleResources().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 GetAlertRuleResource(string alertRuleResourceName, CancellationToken cancellationToken = default) + { + return GetAlertRuleResources().Get(alertRuleResourceName, cancellationToken); + } + + /// Gets a collection of HealthValidationResources in the Watcher. + /// An object representing collection of HealthValidationResources and their operations over a HealthValidationResource. + public virtual HealthValidationCollection GetHealthValidations() + { + return GetCachedClient(client => new HealthValidationCollection(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> GetHealthValidationAsync(string healthValidationName, CancellationToken cancellationToken = default) + { + return await GetHealthValidations().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 GetHealthValidation(string healthValidationName, CancellationToken cancellationToken = default) + { + return GetHealthValidations().Get(healthValidationName, cancellationToken); + } + + /// Gets a collection of TargetResources in the Watcher. + /// An object representing collection of TargetResources and their operations over a TargetResource. + public virtual TargetCollection GetTargets() + { + return GetCachedClient(client => new TargetCollection(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> GetTargetAsync(string targetName, CancellationToken cancellationToken = default) + { + return await GetTargets().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 GetTarget(string targetName, CancellationToken cancellationToken = default) + { + return GetTargets().Get(targetName, cancellationToken); + } + + /// Gets a collection of SharedPrivateLinkResources in the Watcher. + /// An object representing collection of SharedPrivateLinkResources and their operations over a SharedPrivateLinkResource. + public virtual SharedPrivateLinkResourceCollection GetSharedPrivateLinkResources() + { + return GetCachedClient(client => new SharedPrivateLinkResourceCollection(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> GetSharedPrivateLinkResourceAsync(string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) + { + return await GetSharedPrivateLinkResources().GetAsync(sharedPrivateLinkResourceName, cancellationToken).ConfigureAwait(false); + } + + /// + /// 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 GetSharedPrivateLinkResource(string sharedPrivateLinkResourceName, CancellationToken cancellationToken = default) + { + return GetSharedPrivateLinkResources().Get(sharedPrivateLinkResourceName, cancellationToken); + } + + /// + /// 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 + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.Get"); + scope.Start(); + try + { + var response = await _watcherRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new WatcherResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.Get"); + scope.Start(); + try + { + var response = _watcherRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new WatcherResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Watcher + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// + /// + /// Operation Id + /// Watcher_Delete + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.Delete"); + scope.Start(); + try + { + var response = await _watcherRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new DatabaseWatcherArmOperation(_watcherClientDiagnostics, Pipeline, _watcherRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Watcher + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// + /// + /// Operation Id + /// Watcher_Delete + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.Delete"); + scope.Start(); + try + { + var response = _watcherRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new DatabaseWatcherArmOperation(_watcherClientDiagnostics, Pipeline, _watcherRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Watcher + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// + /// + /// Operation Id + /// Watcher_Update + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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, WatcherPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.Update"); + scope.Start(); + try + { + var response = await _watcherRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new DatabaseWatcherArmOperation(new WatcherOperationSource(Client), _watcherClientDiagnostics, Pipeline, _watcherRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Watcher + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName} + /// + /// + /// Operation Id + /// Watcher_Update + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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, WatcherPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.Update"); + scope.Start(); + try + { + var response = _watcherRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + var operation = new DatabaseWatcherArmOperation(new WatcherOperationSource(Client), _watcherClientDiagnostics, Pipeline, _watcherRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// The action to start monitoring all targets configured for a database watcher. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/start + /// + /// + /// Operation Id + /// Watchers_Start + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 cancellation token to use. + public virtual async Task StartAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.Start"); + scope.Start(); + try + { + var response = await _watcherRestClient.StartAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new DatabaseWatcherArmOperation(_watcherClientDiagnostics, Pipeline, _watcherRestClient.CreateStartRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// The action to start monitoring all targets configured for a database watcher. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/start + /// + /// + /// Operation Id + /// Watchers_Start + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 cancellation token to use. + public virtual ArmOperation Start(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.Start"); + scope.Start(); + try + { + var response = _watcherRestClient.Start(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new DatabaseWatcherArmOperation(_watcherClientDiagnostics, Pipeline, _watcherRestClient.CreateStartRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// The action to stop monitoring all targets configured for a database watcher. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/stop + /// + /// + /// Operation Id + /// Watchers_Stop + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 cancellation token to use. + public virtual async Task StopAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.Stop"); + scope.Start(); + try + { + var response = await _watcherRestClient.StopAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new DatabaseWatcherArmOperation(_watcherClientDiagnostics, Pipeline, _watcherRestClient.CreateStopRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// The action to stop monitoring all targets configured for a database watcher. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DatabaseWatcher/watchers/{watcherName}/stop + /// + /// + /// Operation Id + /// Watchers_Stop + /// + /// + /// Default Api Version + /// 2025-01-02 + /// + /// + /// 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 cancellation token to use. + public virtual ArmOperation Stop(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.Stop"); + scope.Start(); + try + { + var response = _watcherRestClient.Stop(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new DatabaseWatcherArmOperation(_watcherClientDiagnostics, Pipeline, _watcherRestClient.CreateStopRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var 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 _watcherRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new WatcherResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new WatcherPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _watcherRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new WatcherResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new WatcherPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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. + /// 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 = _watcherClientDiagnostics.CreateScope("WatcherResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var 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 _watcherRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new WatcherResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new WatcherPatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _watcherRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new WatcherResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new WatcherPatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var 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 _watcherRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new WatcherResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new WatcherPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// 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 + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _watcherClientDiagnostics.CreateScope("WatcherResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _watcherRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new WatcherResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new WatcherPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Properties/AssemblyInfo.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..700c78e5dd7e --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.ResourceManager.DatabaseWatcher.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("DatabaseWatcher")] diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tests/Azure.ResourceManager.DatabaseWatcher.Tests.csproj b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tests/Azure.ResourceManager.DatabaseWatcher.Tests.csproj new file mode 100644 index 000000000000..4107c22780fe --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tests/Azure.ResourceManager.DatabaseWatcher.Tests.csproj @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tests/DatabaseWatcherManagementTestBase.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tests/DatabaseWatcherManagementTestBase.cs new file mode 100644 index 000000000000..752ee1ad5c2e --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tests/DatabaseWatcherManagementTestBase.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure; +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.DatabaseWatcher.Tests +{ + public class DatabaseWatcherManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + + protected DatabaseWatcherManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected DatabaseWatcherManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public async Task CreateCommonClient() + { + Client = GetArmClient(); + DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); + } + + protected async Task CreateResourceGroup(SubscriptionResource subscription, string rgNamePrefix, AzureLocation location) + { + string rgName = Recording.GenerateAssetName(rgNamePrefix); + ResourceGroupData input = new ResourceGroupData(location); + var lro = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, input); + return lro.Value; + } + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tests/DatabaseWatcherManagementTestEnvironment.cs b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tests/DatabaseWatcherManagementTestEnvironment.cs new file mode 100644 index 000000000000..8c72583b0fea --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tests/DatabaseWatcherManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.DatabaseWatcher.Tests +{ + public class DatabaseWatcherManagementTestEnvironment : TestEnvironment + { + } +} diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tsp-location.yaml b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tsp-location.yaml new file mode 100644 index 000000000000..ab9319cecc74 --- /dev/null +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/databasewatcher/DatabaseWatcher.Management +commit: a5e420eea80c7bf89629af151ef60a352adfd411 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/databasewatcher/ci.mgmt.yml b/sdk/databasewatcher/ci.mgmt.yml new file mode 100644 index 000000000000..939cabda31dd --- /dev/null +++ b/sdk/databasewatcher/ci.mgmt.yml @@ -0,0 +1,26 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: none + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/databasewatcher /ci.mgmt.yml + - sdk/databasewatcher /Azure.ResourceManager.DatabaseWatcher / + + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: databasewatcher + ArtifactName: packages + LimitForPullRequest: true + Artifacts: + - name: Azure.ResourceManager.DatabaseWatcher + safeName: AzureResourceManagerDatabaseWatcher diff --git a/sdk/resourcemanager/ci.mgmt.yml b/sdk/resourcemanager/ci.mgmt.yml index d8bf790b5988..77d5bcb09ccb 100644 --- a/sdk/resourcemanager/ci.mgmt.yml +++ b/sdk/resourcemanager/ci.mgmt.yml @@ -56,6 +56,7 @@ trigger: - sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql - sdk/costmanagement/Azure.ResourceManager.CostManagement - sdk/customer-insights/Azure.ResourceManager.CustomerInsights + - sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher - sdk/databox/Azure.ResourceManager.DataBox - sdk/databoxedge/Azure.ResourceManager.DataBoxEdge - sdk/datadog/Azure.ResourceManager.Datadog @@ -79,7 +80,6 @@ trigger: - sdk/dnsresolver/Azure.ResourceManager.DnsResolver - sdk/dynatrace/Azure.ResourceManager.Dynatrace - sdk/edgeorder/Azure.ResourceManager.EdgeOrder - - sdk/iotoperations/Azure.ResourceManager.IotOperations - sdk/edgezones/Azure.ResourceManager.EdgeZones - sdk/elastic/Azure.ResourceManager.Elastic - sdk/elasticsan/Azure.ResourceManager.ElasticSan @@ -108,6 +108,7 @@ trigger: - sdk/iot/Azure.ResourceManager.IotFirmwareDefense - sdk/iotcentral/Azure.ResourceManager.IotCentral - sdk/iothub/Azure.ResourceManager.IotHub + - sdk/iotoperations/Azure.ResourceManager.IotOperations - sdk/keyvault/Azure.ResourceManager.KeyVault - sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration - sdk/kusto/Azure.ResourceManager.Kusto @@ -262,6 +263,7 @@ pr: - sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql - sdk/costmanagement/Azure.ResourceManager.CostManagement - sdk/customer-insights/Azure.ResourceManager.CustomerInsights + - sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher - sdk/databox/Azure.ResourceManager.DataBox - sdk/databoxedge/Azure.ResourceManager.DataBoxEdge - sdk/datadog/Azure.ResourceManager.Datadog @@ -285,7 +287,6 @@ pr: - sdk/dnsresolver/Azure.ResourceManager.DnsResolver - sdk/dynatrace/Azure.ResourceManager.Dynatrace - sdk/edgeorder/Azure.ResourceManager.EdgeOrder - - sdk/iotoperations/Azure.ResourceManager.IotOperations - sdk/edgezones/Azure.ResourceManager.EdgeZones - sdk/elastic/Azure.ResourceManager.Elastic - sdk/elasticsan/Azure.ResourceManager.ElasticSan @@ -314,6 +315,7 @@ pr: - sdk/iot/Azure.ResourceManager.IotFirmwareDefense - sdk/iotcentral/Azure.ResourceManager.IotCentral - sdk/iothub/Azure.ResourceManager.IotHub + - sdk/iotoperations/Azure.ResourceManager.IotOperations - sdk/keyvault/Azure.ResourceManager.KeyVault - sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration - sdk/kusto/Azure.ResourceManager.Kusto