diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionCollection.cs
new file mode 100644
index 000000000000..048920c5ad41
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionCollection.cs
@@ -0,0 +1,314 @@
+// 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.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager;
+using Azure.ResourceManager.Sql.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ ///
+ /// 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 GetDatabaseAdvancedThreatProtections method from an instance of .
+ ///
+ public partial class DatabaseAdvancedThreatProtectionCollection : ArmCollection, IEnumerable, IAsyncEnumerable
+ {
+ private readonly ClientDiagnostics _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics;
+ private readonly DatabaseAdvancedThreatProtectionSettingsRestOperations _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient;
+
+ /// Initializes a new instance of the class for mocking.
+ protected DatabaseAdvancedThreatProtectionCollection()
+ {
+ }
+
+ /// 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 DatabaseAdvancedThreatProtectionCollection(ArmClient client, ResourceIdentifier id) : base(client, id)
+ {
+ _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sql", DatabaseAdvancedThreatProtectionResource.ResourceType.Namespace, Diagnostics);
+ TryGetApiVersion(DatabaseAdvancedThreatProtectionResource.ResourceType, out string databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsApiVersion);
+ _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient = new DatabaseAdvancedThreatProtectionSettingsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsApiVersion);
+#if DEBUG
+ ValidateResourceId(Id);
+#endif
+ }
+
+ internal static void ValidateResourceId(ResourceIdentifier id)
+ {
+ if (id.ResourceType != SqlDatabaseResource.ResourceType)
+ throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, SqlDatabaseResource.ResourceType), nameof(id));
+ }
+
+ ///
+ /// Creates or updates a database's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: DatabaseAdvancedThreatProtectionSettings_CreateOrUpdate
+ ///
+ /// 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 name of the Advanced Threat Protection state.
+ /// The database Advanced Threat Protection state.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, AdvancedThreatProtectionName advancedThreatProtectionName, DatabaseAdvancedThreatProtectionData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(data, nameof(data));
+
+ using var scope = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("DatabaseAdvancedThreatProtectionCollection.CreateOrUpdate");
+ scope.Start();
+ try
+ {
+ var response = await _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, advancedThreatProtectionName, data, cancellationToken).ConfigureAwait(false);
+ var operation = new SqlArmOperation(Response.FromValue(new DatabaseAdvancedThreatProtectionResource(Client, response), response.GetRawResponse()));
+ if (waitUntil == WaitUntil.Completed)
+ await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Creates or updates a database's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: DatabaseAdvancedThreatProtectionSettings_CreateOrUpdate
+ ///
+ /// 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 name of the Advanced Threat Protection state.
+ /// The database Advanced Threat Protection state.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, AdvancedThreatProtectionName advancedThreatProtectionName, DatabaseAdvancedThreatProtectionData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(data, nameof(data));
+
+ using var scope = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("DatabaseAdvancedThreatProtectionCollection.CreateOrUpdate");
+ scope.Start();
+ try
+ {
+ var response = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, advancedThreatProtectionName, data, cancellationToken);
+ var operation = new SqlArmOperation(Response.FromValue(new DatabaseAdvancedThreatProtectionResource(Client, response), response.GetRawResponse()));
+ if (waitUntil == WaitUntil.Completed)
+ operation.WaitForCompletion(cancellationToken);
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Gets a database's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: DatabaseAdvancedThreatProtectionSettings_Get
+ ///
+ /// The name of the Advanced Threat Protection state.
+ /// The cancellation token to use.
+ public virtual async Task> GetAsync(AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ using var scope = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("DatabaseAdvancedThreatProtectionCollection.Get");
+ scope.Start();
+ try
+ {
+ var response = await _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, advancedThreatProtectionName, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw new RequestFailedException(response.GetRawResponse());
+ return Response.FromValue(new DatabaseAdvancedThreatProtectionResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Gets a database's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: DatabaseAdvancedThreatProtectionSettings_Get
+ ///
+ /// The name of the Advanced Threat Protection state.
+ /// The cancellation token to use.
+ public virtual Response Get(AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ using var scope = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("DatabaseAdvancedThreatProtectionCollection.Get");
+ scope.Start();
+ try
+ {
+ var response = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, advancedThreatProtectionName, cancellationToken);
+ if (response.Value == null)
+ throw new RequestFailedException(response.GetRawResponse());
+ return Response.FromValue(new DatabaseAdvancedThreatProtectionResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Gets a list of database's Advanced Threat Protection states.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings
+ /// Operation Id: DatabaseAdvancedThreatProtectionSettings_ListByDatabase
+ ///
+ /// 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)
+ {
+ async Task> FirstPageFunc(int? pageSizeHint)
+ {
+ using var scope = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("DatabaseAdvancedThreatProtectionCollection.GetAll");
+ scope.Start();
+ try
+ {
+ var response = await _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient.ListByDatabaseAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Page.FromValues(response.Value.Value.Select(value => new DatabaseAdvancedThreatProtectionResource(Client, value)), response.Value.NextLink, response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ async Task> NextPageFunc(string nextLink, int? pageSizeHint)
+ {
+ using var scope = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("DatabaseAdvancedThreatProtectionCollection.GetAll");
+ scope.Start();
+ try
+ {
+ var response = await _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient.ListByDatabaseNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Page.FromValues(response.Value.Value.Select(value => new DatabaseAdvancedThreatProtectionResource(Client, value)), response.Value.NextLink, response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
+ }
+
+ ///
+ /// Gets a list of database's Advanced Threat Protection states.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings
+ /// Operation Id: DatabaseAdvancedThreatProtectionSettings_ListByDatabase
+ ///
+ /// The cancellation token to use.
+ /// A collection of that may take multiple service requests to iterate over.
+ public virtual Pageable GetAll(CancellationToken cancellationToken = default)
+ {
+ Page FirstPageFunc(int? pageSizeHint)
+ {
+ using var scope = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("DatabaseAdvancedThreatProtectionCollection.GetAll");
+ scope.Start();
+ try
+ {
+ var response = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient.ListByDatabase(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken: cancellationToken);
+ return Page.FromValues(response.Value.Value.Select(value => new DatabaseAdvancedThreatProtectionResource(Client, value)), response.Value.NextLink, response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ Page NextPageFunc(string nextLink, int? pageSizeHint)
+ {
+ using var scope = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("DatabaseAdvancedThreatProtectionCollection.GetAll");
+ scope.Start();
+ try
+ {
+ var response = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient.ListByDatabaseNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken: cancellationToken);
+ return Page.FromValues(response.Value.Value.Select(value => new DatabaseAdvancedThreatProtectionResource(Client, value)), response.Value.NextLink, response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
+ }
+
+ ///
+ /// Checks to see if the resource exists in azure.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: DatabaseAdvancedThreatProtectionSettings_Get
+ ///
+ /// The name of the Advanced Threat Protection state.
+ /// The cancellation token to use.
+ public virtual async Task> ExistsAsync(AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ using var scope = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("DatabaseAdvancedThreatProtectionCollection.Exists");
+ scope.Start();
+ try
+ {
+ var response = await _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, advancedThreatProtectionName, 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.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: DatabaseAdvancedThreatProtectionSettings_Get
+ ///
+ /// The name of the Advanced Threat Protection state.
+ /// The cancellation token to use.
+ public virtual Response Exists(AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ using var scope = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("DatabaseAdvancedThreatProtectionCollection.Exists");
+ scope.Start();
+ try
+ {
+ var response = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, advancedThreatProtectionName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, 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/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionData.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionData.cs
new file mode 100644
index 000000000000..8d0f68322d2c
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionData.cs
@@ -0,0 +1,41 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure.Core;
+using Azure.ResourceManager.Models;
+using Azure.ResourceManager.Sql.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ /// A class representing the DatabaseAdvancedThreatProtection data model.
+ public partial class DatabaseAdvancedThreatProtectionData : ResourceData
+ {
+ /// Initializes a new instance of DatabaseAdvancedThreatProtectionData.
+ public DatabaseAdvancedThreatProtectionData()
+ {
+ }
+
+ /// Initializes a new instance of DatabaseAdvancedThreatProtectionData.
+ /// The id.
+ /// The name.
+ /// The resourceType.
+ /// The systemData.
+ /// Specifies the state of the Advanced Threat Protection, whether it is enabled or disabled or a state has not been applied yet on the specific database or server.
+ /// Specifies the UTC creation time of the policy.
+ internal DatabaseAdvancedThreatProtectionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, AdvancedThreatProtectionState? state, DateTimeOffset? creationOn) : base(id, name, resourceType, systemData)
+ {
+ State = state;
+ CreationOn = creationOn;
+ }
+
+ /// Specifies the state of the Advanced Threat Protection, whether it is enabled or disabled or a state has not been applied yet on the specific database or server.
+ public AdvancedThreatProtectionState? State { get; set; }
+ /// Specifies the UTC creation time of the policy.
+ public DateTimeOffset? CreationOn { get; }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionResource.cs
new file mode 100644
index 000000000000..f142bde27e22
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionResource.cs
@@ -0,0 +1,198 @@
+// 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;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager;
+using Azure.ResourceManager.Sql.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ ///
+ /// A Class representing a DatabaseAdvancedThreatProtection 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 GetDatabaseAdvancedThreatProtectionResource method.
+ /// Otherwise you can get one from its parent resource using the GetDatabaseAdvancedThreatProtection method.
+ ///
+ public partial class DatabaseAdvancedThreatProtectionResource : ArmResource
+ {
+ /// Generate the resource identifier of a instance.
+ public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string serverName, string databaseName, string advancedThreatProtectionName)
+ {
+ var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}";
+ return new ResourceIdentifier(resourceId);
+ }
+
+ private readonly ClientDiagnostics _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics;
+ private readonly DatabaseAdvancedThreatProtectionSettingsRestOperations _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient;
+ private readonly DatabaseAdvancedThreatProtectionData _data;
+
+ /// Initializes a new instance of the class for mocking.
+ protected DatabaseAdvancedThreatProtectionResource()
+ {
+ }
+
+ /// Initializes a new instance of the class.
+ /// The client parameters to use in these operations.
+ /// The resource that is the target of operations.
+ internal DatabaseAdvancedThreatProtectionResource(ArmClient client, DatabaseAdvancedThreatProtectionData 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 DatabaseAdvancedThreatProtectionResource(ArmClient client, ResourceIdentifier id) : base(client, id)
+ {
+ _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sql", ResourceType.Namespace, Diagnostics);
+ TryGetApiVersion(ResourceType, out string databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsApiVersion);
+ _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient = new DatabaseAdvancedThreatProtectionSettingsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsApiVersion);
+#if DEBUG
+ ValidateResourceId(Id);
+#endif
+ }
+
+ /// Gets the resource type for the operations.
+ public static readonly ResourceType ResourceType = "Microsoft.Sql/servers/databases/advancedThreatProtectionSettings";
+
+ /// 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 DatabaseAdvancedThreatProtectionData 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 database's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: DatabaseAdvancedThreatProtectionSettings_Get
+ ///
+ /// The cancellation token to use.
+ public virtual async Task> GetAsync(CancellationToken cancellationToken = default)
+ {
+ using var scope = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("DatabaseAdvancedThreatProtectionResource.Get");
+ scope.Start();
+ try
+ {
+ var response = await _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw new RequestFailedException(response.GetRawResponse());
+ return Response.FromValue(new DatabaseAdvancedThreatProtectionResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Gets a database's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: DatabaseAdvancedThreatProtectionSettings_Get
+ ///
+ /// The cancellation token to use.
+ public virtual Response Get(CancellationToken cancellationToken = default)
+ {
+ using var scope = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("DatabaseAdvancedThreatProtectionResource.Get");
+ scope.Start();
+ try
+ {
+ var response = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw new RequestFailedException(response.GetRawResponse());
+ return Response.FromValue(new DatabaseAdvancedThreatProtectionResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Creates or updates a database's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: DatabaseAdvancedThreatProtectionSettings_CreateOrUpdate
+ ///
+ /// 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 Advanced Threat Protection state.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual async Task> UpdateAsync(WaitUntil waitUntil, DatabaseAdvancedThreatProtectionData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(data, nameof(data));
+
+ using var scope = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("DatabaseAdvancedThreatProtectionResource.Update");
+ scope.Start();
+ try
+ {
+ var response = await _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false);
+ var operation = new SqlArmOperation(Response.FromValue(new DatabaseAdvancedThreatProtectionResource(Client, response), response.GetRawResponse()));
+ if (waitUntil == WaitUntil.Completed)
+ await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Creates or updates a database's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: DatabaseAdvancedThreatProtectionSettings_CreateOrUpdate
+ ///
+ /// 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 Advanced Threat Protection state.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual ArmOperation Update(WaitUntil waitUntil, DatabaseAdvancedThreatProtectionData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(data, nameof(data));
+
+ using var scope = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("DatabaseAdvancedThreatProtectionResource.Update");
+ scope.Start();
+ try
+ {
+ var response = _databaseAdvancedThreatProtectionDatabaseAdvancedThreatProtectionSettingsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, data, cancellationToken);
+ var operation = new SqlArmOperation(Response.FromValue(new DatabaseAdvancedThreatProtectionResource(Client, response), response.GetRawResponse()));
+ if (waitUntil == WaitUntil.Completed)
+ operation.WaitForCompletion(cancellationToken);
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/SqlExtensions.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/SqlExtensions.cs
index 5d4326f6b238..4d3488dc991c 100644
--- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/SqlExtensions.cs
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/SqlExtensions.cs
@@ -3263,5 +3263,62 @@ public static ExtendedServerBlobAuditingPolicyResource GetExtendedServerBlobAudi
);
}
#endregion
+
+ #region DatabaseAdvancedThreatProtectionResource
+ ///
+ /// 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 instance the method will execute against.
+ /// The resource ID of the resource to get.
+ /// Returns a object.
+ public static DatabaseAdvancedThreatProtectionResource GetDatabaseAdvancedThreatProtectionResource(this ArmClient client, ResourceIdentifier id)
+ {
+ return client.GetResourceClient(() =>
+ {
+ DatabaseAdvancedThreatProtectionResource.ValidateResourceId(id);
+ return new DatabaseAdvancedThreatProtectionResource(client, id);
+ }
+ );
+ }
+ #endregion
+
+ #region ServerAdvancedThreatProtectionResource
+ ///
+ /// 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 instance the method will execute against.
+ /// The resource ID of the resource to get.
+ /// Returns a object.
+ public static ServerAdvancedThreatProtectionResource GetServerAdvancedThreatProtectionResource(this ArmClient client, ResourceIdentifier id)
+ {
+ return client.GetResourceClient(() =>
+ {
+ ServerAdvancedThreatProtectionResource.ValidateResourceId(id);
+ return new ServerAdvancedThreatProtectionResource(client, id);
+ }
+ );
+ }
+ #endregion
+
+ #region ManagedServerDnsAliasResource
+ ///
+ /// 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 instance the method will execute against.
+ /// The resource ID of the resource to get.
+ /// Returns a object.
+ public static ManagedServerDnsAliasResource GetManagedServerDnsAliasResource(this ArmClient client, ResourceIdentifier id)
+ {
+ return client.GetResourceClient(() =>
+ {
+ ManagedServerDnsAliasResource.ValidateResourceId(id);
+ return new ManagedServerDnsAliasResource(client, id);
+ }
+ );
+ }
+ #endregion
}
}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/ManagedServerDnsAliasOperationSource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/ManagedServerDnsAliasOperationSource.cs
new file mode 100644
index 000000000000..1584715c6788
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/ManagedServerDnsAliasOperationSource.cs
@@ -0,0 +1,40 @@
+// 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;
+using Azure.Core;
+using Azure.ResourceManager;
+
+namespace Azure.ResourceManager.Sql
+{
+ internal class ManagedServerDnsAliasOperationSource : IOperationSource
+ {
+ private readonly ArmClient _client;
+
+ internal ManagedServerDnsAliasOperationSource(ArmClient client)
+ {
+ _client = client;
+ }
+
+ ManagedServerDnsAliasResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken)
+ {
+ using var document = JsonDocument.Parse(response.ContentStream);
+ var data = ManagedServerDnsAliasData.DeserializeManagedServerDnsAliasData(document.RootElement);
+ return new ManagedServerDnsAliasResource(_client, data);
+ }
+
+ async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken)
+ {
+ using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
+ var data = ManagedServerDnsAliasData.DeserializeManagedServerDnsAliasData(document.RootElement);
+ return new ManagedServerDnsAliasResource(_client, data);
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/ServerAdvancedThreatProtectionOperationSource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/ServerAdvancedThreatProtectionOperationSource.cs
new file mode 100644
index 000000000000..b24231868949
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/ServerAdvancedThreatProtectionOperationSource.cs
@@ -0,0 +1,40 @@
+// 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;
+using Azure.Core;
+using Azure.ResourceManager;
+
+namespace Azure.ResourceManager.Sql
+{
+ internal class ServerAdvancedThreatProtectionOperationSource : IOperationSource
+ {
+ private readonly ArmClient _client;
+
+ internal ServerAdvancedThreatProtectionOperationSource(ArmClient client)
+ {
+ _client = client;
+ }
+
+ ServerAdvancedThreatProtectionResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken)
+ {
+ using var document = JsonDocument.Parse(response.ContentStream);
+ var data = ServerAdvancedThreatProtectionData.DeserializeServerAdvancedThreatProtectionData(document.RootElement);
+ return new ServerAdvancedThreatProtectionResource(_client, data);
+ }
+
+ async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken)
+ {
+ using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
+ var data = ServerAdvancedThreatProtectionData.DeserializeServerAdvancedThreatProtectionData(document.RootElement);
+ return new ServerAdvancedThreatProtectionResource(_client, data);
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceResource.cs
index 2fe56def57db..164be4f9babe 100644
--- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceResource.cs
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceResource.cs
@@ -642,6 +642,43 @@ public virtual Response GetEndpointCertificate(stri
return GetEndpointCertificates().Get(endpointType, cancellationToken);
}
+ /// Gets a collection of ManagedServerDnsAliasResources in the ManagedInstance.
+ /// An object representing collection of ManagedServerDnsAliasResources and their operations over a ManagedServerDnsAliasResource.
+ public virtual ManagedServerDnsAliasCollection GetManagedServerDnsAliases()
+ {
+ return GetCachedClient(Client => new ManagedServerDnsAliasCollection(Client, Id));
+ }
+
+ ///
+ /// Gets a server DNS alias.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}
+ /// Operation Id: ManagedServerDnsAliases_Get
+ ///
+ /// The String to use.
+ /// The cancellation token to use.
+ /// is an empty string, and was expected to be non-empty.
+ /// is null.
+ [ForwardsClientCalls]
+ public virtual async Task> GetManagedServerDnsAliasAsync(string dnsAliasName, CancellationToken cancellationToken = default)
+ {
+ return await GetManagedServerDnsAliases().GetAsync(dnsAliasName, cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// Gets a server DNS alias.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}
+ /// Operation Id: ManagedServerDnsAliases_Get
+ ///
+ /// The String to use.
+ /// The cancellation token to use.
+ /// is an empty string, and was expected to be non-empty.
+ /// is null.
+ [ForwardsClientCalls]
+ public virtual Response GetManagedServerDnsAlias(string dnsAliasName, CancellationToken cancellationToken = default)
+ {
+ return GetManagedServerDnsAliases().Get(dnsAliasName, cancellationToken);
+ }
+
///
/// Gets a managed instance.
/// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerDnsAliasCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerDnsAliasCollection.cs
new file mode 100644
index 000000000000..b47ab39a2305
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerDnsAliasCollection.cs
@@ -0,0 +1,334 @@
+// 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.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager;
+using Azure.ResourceManager.Sql.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ ///
+ /// 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 GetManagedServerDnsAliases method from an instance of .
+ ///
+ public partial class ManagedServerDnsAliasCollection : ArmCollection, IEnumerable, IAsyncEnumerable
+ {
+ private readonly ClientDiagnostics _managedServerDnsAliasClientDiagnostics;
+ private readonly ManagedServerDnsAliasesRestOperations _managedServerDnsAliasRestClient;
+
+ /// Initializes a new instance of the class for mocking.
+ protected ManagedServerDnsAliasCollection()
+ {
+ }
+
+ /// 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 ManagedServerDnsAliasCollection(ArmClient client, ResourceIdentifier id) : base(client, id)
+ {
+ _managedServerDnsAliasClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sql", ManagedServerDnsAliasResource.ResourceType.Namespace, Diagnostics);
+ TryGetApiVersion(ManagedServerDnsAliasResource.ResourceType, out string managedServerDnsAliasApiVersion);
+ _managedServerDnsAliasRestClient = new ManagedServerDnsAliasesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedServerDnsAliasApiVersion);
+#if DEBUG
+ ValidateResourceId(Id);
+#endif
+ }
+
+ internal static void ValidateResourceId(ResourceIdentifier id)
+ {
+ if (id.ResourceType != ManagedInstanceResource.ResourceType)
+ throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ManagedInstanceResource.ResourceType), nameof(id));
+ }
+
+ ///
+ /// Creates a managed server DNS alias.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}
+ /// Operation Id: ManagedServerDnsAliases_CreateOrUpdate
+ ///
+ /// 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 String to use.
+ /// The ManagedServerDnsAliasCreateOrUpdateContent to use.
+ /// 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 dnsAliasName, ManagedServerDnsAliasCreateOrUpdateContent content, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(dnsAliasName, nameof(dnsAliasName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasCollection.CreateOrUpdate");
+ scope.Start();
+ try
+ {
+ var response = await _managedServerDnsAliasRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dnsAliasName, content, cancellationToken).ConfigureAwait(false);
+ var operation = new SqlArmOperation(new ManagedServerDnsAliasOperationSource(Client), _managedServerDnsAliasClientDiagnostics, Pipeline, _managedServerDnsAliasRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dnsAliasName, content).Request, response, OperationFinalStateVia.Location);
+ if (waitUntil == WaitUntil.Completed)
+ await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Creates a managed server DNS alias.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}
+ /// Operation Id: ManagedServerDnsAliases_CreateOrUpdate
+ ///
+ /// 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 String to use.
+ /// The ManagedServerDnsAliasCreateOrUpdateContent to use.
+ /// 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 dnsAliasName, ManagedServerDnsAliasCreateOrUpdateContent content, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(dnsAliasName, nameof(dnsAliasName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasCollection.CreateOrUpdate");
+ scope.Start();
+ try
+ {
+ var response = _managedServerDnsAliasRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dnsAliasName, content, cancellationToken);
+ var operation = new SqlArmOperation(new ManagedServerDnsAliasOperationSource(Client), _managedServerDnsAliasClientDiagnostics, Pipeline, _managedServerDnsAliasRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dnsAliasName, content).Request, response, OperationFinalStateVia.Location);
+ if (waitUntil == WaitUntil.Completed)
+ operation.WaitForCompletion(cancellationToken);
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Gets a server DNS alias.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}
+ /// Operation Id: ManagedServerDnsAliases_Get
+ ///
+ /// The String to use.
+ /// The cancellation token to use.
+ /// is an empty string, and was expected to be non-empty.
+ /// is null.
+ public virtual async Task> GetAsync(string dnsAliasName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(dnsAliasName, nameof(dnsAliasName));
+
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasCollection.Get");
+ scope.Start();
+ try
+ {
+ var response = await _managedServerDnsAliasRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dnsAliasName, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw new RequestFailedException(response.GetRawResponse());
+ return Response.FromValue(new ManagedServerDnsAliasResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Gets a server DNS alias.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}
+ /// Operation Id: ManagedServerDnsAliases_Get
+ ///
+ /// The String to use.
+ /// The cancellation token to use.
+ /// is an empty string, and was expected to be non-empty.
+ /// is null.
+ public virtual Response Get(string dnsAliasName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(dnsAliasName, nameof(dnsAliasName));
+
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasCollection.Get");
+ scope.Start();
+ try
+ {
+ var response = _managedServerDnsAliasRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dnsAliasName, cancellationToken);
+ if (response.Value == null)
+ throw new RequestFailedException(response.GetRawResponse());
+ return Response.FromValue(new ManagedServerDnsAliasResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Gets a list of managed server DNS aliases for a managed server.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases
+ /// Operation Id: ManagedServerDnsAliases_ListByManagedInstance
+ ///
+ /// 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)
+ {
+ async Task> FirstPageFunc(int? pageSizeHint)
+ {
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasCollection.GetAll");
+ scope.Start();
+ try
+ {
+ var response = await _managedServerDnsAliasRestClient.ListByManagedInstanceAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Page.FromValues(response.Value.Value.Select(value => new ManagedServerDnsAliasResource(Client, value)), response.Value.NextLink, response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ async Task> NextPageFunc(string nextLink, int? pageSizeHint)
+ {
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasCollection.GetAll");
+ scope.Start();
+ try
+ {
+ var response = await _managedServerDnsAliasRestClient.ListByManagedInstanceNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Page.FromValues(response.Value.Value.Select(value => new ManagedServerDnsAliasResource(Client, value)), response.Value.NextLink, response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
+ }
+
+ ///
+ /// Gets a list of managed server DNS aliases for a managed server.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases
+ /// Operation Id: ManagedServerDnsAliases_ListByManagedInstance
+ ///
+ /// The cancellation token to use.
+ /// A collection of that may take multiple service requests to iterate over.
+ public virtual Pageable GetAll(CancellationToken cancellationToken = default)
+ {
+ Page FirstPageFunc(int? pageSizeHint)
+ {
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasCollection.GetAll");
+ scope.Start();
+ try
+ {
+ var response = _managedServerDnsAliasRestClient.ListByManagedInstance(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken);
+ return Page.FromValues(response.Value.Value.Select(value => new ManagedServerDnsAliasResource(Client, value)), response.Value.NextLink, response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ Page NextPageFunc(string nextLink, int? pageSizeHint)
+ {
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasCollection.GetAll");
+ scope.Start();
+ try
+ {
+ var response = _managedServerDnsAliasRestClient.ListByManagedInstanceNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken);
+ return Page.FromValues(response.Value.Value.Select(value => new ManagedServerDnsAliasResource(Client, value)), response.Value.NextLink, response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
+ }
+
+ ///
+ /// Checks to see if the resource exists in azure.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}
+ /// Operation Id: ManagedServerDnsAliases_Get
+ ///
+ /// The String to use.
+ /// The cancellation token to use.
+ /// is an empty string, and was expected to be non-empty.
+ /// is null.
+ public virtual async Task> ExistsAsync(string dnsAliasName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(dnsAliasName, nameof(dnsAliasName));
+
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasCollection.Exists");
+ scope.Start();
+ try
+ {
+ var response = await _managedServerDnsAliasRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dnsAliasName, 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.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}
+ /// Operation Id: ManagedServerDnsAliases_Get
+ ///
+ /// The String to use.
+ /// The cancellation token to use.
+ /// is an empty string, and was expected to be non-empty.
+ /// is null.
+ public virtual Response Exists(string dnsAliasName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(dnsAliasName, nameof(dnsAliasName));
+
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasCollection.Exists");
+ scope.Start();
+ try
+ {
+ var response = _managedServerDnsAliasRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, dnsAliasName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, 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/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerDnsAliasData.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerDnsAliasData.cs
new file mode 100644
index 000000000000..f04273705ba2
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerDnsAliasData.cs
@@ -0,0 +1,39 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using Azure.Core;
+using Azure.ResourceManager.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ /// A class representing the ManagedServerDnsAlias data model.
+ public partial class ManagedServerDnsAliasData : ResourceData
+ {
+ /// Initializes a new instance of ManagedServerDnsAliasData.
+ public ManagedServerDnsAliasData()
+ {
+ }
+
+ /// Initializes a new instance of ManagedServerDnsAliasData.
+ /// The id.
+ /// The name.
+ /// The resourceType.
+ /// The systemData.
+ /// The fully qualified DNS record for managed server alias.
+ /// The fully qualified public DNS record for managed server alias.
+ internal ManagedServerDnsAliasData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string azureDnsRecord, string publicAzureDnsRecord) : base(id, name, resourceType, systemData)
+ {
+ AzureDnsRecord = azureDnsRecord;
+ PublicAzureDnsRecord = publicAzureDnsRecord;
+ }
+
+ /// The fully qualified DNS record for managed server alias.
+ public string AzureDnsRecord { get; }
+ /// The fully qualified public DNS record for managed server alias.
+ public string PublicAzureDnsRecord { get; }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerDnsAliasResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerDnsAliasResource.cs
new file mode 100644
index 000000000000..138ea4c42da8
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedServerDnsAliasResource.cs
@@ -0,0 +1,310 @@
+// 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;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager;
+using Azure.ResourceManager.Sql.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ ///
+ /// A Class representing a ManagedServerDnsAlias 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 GetManagedServerDnsAliasResource method.
+ /// Otherwise you can get one from its parent resource using the GetManagedServerDnsAlias method.
+ ///
+ public partial class ManagedServerDnsAliasResource : ArmResource
+ {
+ /// Generate the resource identifier of a instance.
+ public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string managedInstanceName, string dnsAliasName)
+ {
+ var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}";
+ return new ResourceIdentifier(resourceId);
+ }
+
+ private readonly ClientDiagnostics _managedServerDnsAliasClientDiagnostics;
+ private readonly ManagedServerDnsAliasesRestOperations _managedServerDnsAliasRestClient;
+ private readonly ManagedServerDnsAliasData _data;
+
+ /// Initializes a new instance of the class for mocking.
+ protected ManagedServerDnsAliasResource()
+ {
+ }
+
+ /// Initializes a new instance of the class.
+ /// The client parameters to use in these operations.
+ /// The resource that is the target of operations.
+ internal ManagedServerDnsAliasResource(ArmClient client, ManagedServerDnsAliasData 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 ManagedServerDnsAliasResource(ArmClient client, ResourceIdentifier id) : base(client, id)
+ {
+ _managedServerDnsAliasClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sql", ResourceType.Namespace, Diagnostics);
+ TryGetApiVersion(ResourceType, out string managedServerDnsAliasApiVersion);
+ _managedServerDnsAliasRestClient = new ManagedServerDnsAliasesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, managedServerDnsAliasApiVersion);
+#if DEBUG
+ ValidateResourceId(Id);
+#endif
+ }
+
+ /// Gets the resource type for the operations.
+ public static readonly ResourceType ResourceType = "Microsoft.Sql/managedInstances/dnsAliases";
+
+ /// 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 ManagedServerDnsAliasData 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 server DNS alias.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}
+ /// Operation Id: ManagedServerDnsAliases_Get
+ ///
+ /// The cancellation token to use.
+ public virtual async Task> GetAsync(CancellationToken cancellationToken = default)
+ {
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasResource.Get");
+ scope.Start();
+ try
+ {
+ var response = await _managedServerDnsAliasRestClient.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 ManagedServerDnsAliasResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Gets a server DNS alias.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}
+ /// Operation Id: ManagedServerDnsAliases_Get
+ ///
+ /// The cancellation token to use.
+ public virtual Response Get(CancellationToken cancellationToken = default)
+ {
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasResource.Get");
+ scope.Start();
+ try
+ {
+ var response = _managedServerDnsAliasRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw new RequestFailedException(response.GetRawResponse());
+ return Response.FromValue(new ManagedServerDnsAliasResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Deletes the managed server DNS alias with the given name.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}
+ /// Operation Id: ManagedServerDnsAliases_Delete
+ ///
+ /// 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 = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasResource.Delete");
+ scope.Start();
+ try
+ {
+ var response = await _managedServerDnsAliasRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false);
+ var operation = new SqlArmOperation(_managedServerDnsAliasClientDiagnostics, Pipeline, _managedServerDnsAliasRestClient.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;
+ }
+ }
+
+ ///
+ /// Deletes the managed server DNS alias with the given name.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}
+ /// Operation Id: ManagedServerDnsAliases_Delete
+ ///
+ /// 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 = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasResource.Delete");
+ scope.Start();
+ try
+ {
+ var response = _managedServerDnsAliasRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken);
+ var operation = new SqlArmOperation(_managedServerDnsAliasClientDiagnostics, Pipeline, _managedServerDnsAliasRestClient.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;
+ }
+ }
+
+ ///
+ /// Creates a managed server DNS alias.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}
+ /// Operation Id: ManagedServerDnsAliases_CreateOrUpdate
+ ///
+ /// 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 ManagedServerDnsAliasCreateOrUpdateContent to use.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual async Task> UpdateAsync(WaitUntil waitUntil, ManagedServerDnsAliasCreateOrUpdateContent content, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasResource.Update");
+ scope.Start();
+ try
+ {
+ var response = await _managedServerDnsAliasRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken).ConfigureAwait(false);
+ var operation = new SqlArmOperation(new ManagedServerDnsAliasOperationSource(Client), _managedServerDnsAliasClientDiagnostics, Pipeline, _managedServerDnsAliasRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content).Request, response, OperationFinalStateVia.Location);
+ if (waitUntil == WaitUntil.Completed)
+ await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Creates a managed server DNS alias.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}
+ /// Operation Id: ManagedServerDnsAliases_CreateOrUpdate
+ ///
+ /// 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 ManagedServerDnsAliasCreateOrUpdateContent to use.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual ArmOperation Update(WaitUntil waitUntil, ManagedServerDnsAliasCreateOrUpdateContent content, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasResource.Update");
+ scope.Start();
+ try
+ {
+ var response = _managedServerDnsAliasRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken);
+ var operation = new SqlArmOperation(new ManagedServerDnsAliasOperationSource(Client), _managedServerDnsAliasClientDiagnostics, Pipeline, _managedServerDnsAliasRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content).Request, response, OperationFinalStateVia.Location);
+ if (waitUntil == WaitUntil.Completed)
+ operation.WaitForCompletion(cancellationToken);
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Acquires managed server DNS alias from another managed server.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}/acquire
+ /// Operation Id: ManagedServerDnsAliases_Acquire
+ ///
+ /// 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 ManagedServerDnsAliasAcquisition to use.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual async Task> AcquireAsync(WaitUntil waitUntil, ManagedServerDnsAliasAcquisition managedServerDnsAliasAcquisition, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(managedServerDnsAliasAcquisition, nameof(managedServerDnsAliasAcquisition));
+
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasResource.Acquire");
+ scope.Start();
+ try
+ {
+ var response = await _managedServerDnsAliasRestClient.AcquireAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, managedServerDnsAliasAcquisition, cancellationToken).ConfigureAwait(false);
+ var operation = new SqlArmOperation(new ManagedServerDnsAliasOperationSource(Client), _managedServerDnsAliasClientDiagnostics, Pipeline, _managedServerDnsAliasRestClient.CreateAcquireRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, managedServerDnsAliasAcquisition).Request, response, OperationFinalStateVia.Location);
+ if (waitUntil == WaitUntil.Completed)
+ await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Acquires managed server DNS alias from another managed server.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/dnsAliases/{dnsAliasName}/acquire
+ /// Operation Id: ManagedServerDnsAliases_Acquire
+ ///
+ /// 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 ManagedServerDnsAliasAcquisition to use.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual ArmOperation Acquire(WaitUntil waitUntil, ManagedServerDnsAliasAcquisition managedServerDnsAliasAcquisition, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(managedServerDnsAliasAcquisition, nameof(managedServerDnsAliasAcquisition));
+
+ using var scope = _managedServerDnsAliasClientDiagnostics.CreateScope("ManagedServerDnsAliasResource.Acquire");
+ scope.Start();
+ try
+ {
+ var response = _managedServerDnsAliasRestClient.Acquire(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, managedServerDnsAliasAcquisition, cancellationToken);
+ var operation = new SqlArmOperation(new ManagedServerDnsAliasOperationSource(Client), _managedServerDnsAliasClientDiagnostics, Pipeline, _managedServerDnsAliasRestClient.CreateAcquireRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, managedServerDnsAliasAcquisition).Request, response, OperationFinalStateVia.Location);
+ if (waitUntil == WaitUntil.Completed)
+ operation.WaitForCompletion(cancellationToken);
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdvancedThreatProtectionName.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdvancedThreatProtectionName.cs
new file mode 100644
index 000000000000..9aa361bcbcfc
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdvancedThreatProtectionName.cs
@@ -0,0 +1,48 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ComponentModel;
+
+namespace Azure.ResourceManager.Sql.Models
+{
+ /// The AdvancedThreatProtectionName.
+ public readonly partial struct AdvancedThreatProtectionName : IEquatable
+ {
+ private readonly string _value;
+
+ /// Initializes a new instance of .
+ /// is null.
+ public AdvancedThreatProtectionName(string value)
+ {
+ _value = value ?? throw new ArgumentNullException(nameof(value));
+ }
+
+ private const string DefaultValue = "Default";
+
+ /// Default.
+ public static AdvancedThreatProtectionName Default { get; } = new AdvancedThreatProtectionName(DefaultValue);
+ /// Determines if two values are the same.
+ public static bool operator ==(AdvancedThreatProtectionName left, AdvancedThreatProtectionName right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(AdvancedThreatProtectionName left, AdvancedThreatProtectionName right) => !left.Equals(right);
+ /// Converts a string to a .
+ public static implicit operator AdvancedThreatProtectionName(string value) => new AdvancedThreatProtectionName(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is AdvancedThreatProtectionName other && Equals(other);
+ ///
+ public bool Equals(AdvancedThreatProtectionName other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override int GetHashCode() => _value?.GetHashCode() ?? 0;
+ ///
+ public override string ToString() => _value;
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdvancedThreatProtectionState.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdvancedThreatProtectionState.Serialization.cs
new file mode 100644
index 000000000000..af327b95742e
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdvancedThreatProtectionState.Serialization.cs
@@ -0,0 +1,30 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+
+namespace Azure.ResourceManager.Sql.Models
+{
+ internal static partial class AdvancedThreatProtectionStateExtensions
+ {
+ public static string ToSerialString(this AdvancedThreatProtectionState value) => value switch
+ {
+ AdvancedThreatProtectionState.New => "New",
+ AdvancedThreatProtectionState.Enabled => "Enabled",
+ AdvancedThreatProtectionState.Disabled => "Disabled",
+ _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AdvancedThreatProtectionState value.")
+ };
+
+ public static AdvancedThreatProtectionState ToAdvancedThreatProtectionState(this string value)
+ {
+ if (string.Equals(value, "New", StringComparison.InvariantCultureIgnoreCase)) return AdvancedThreatProtectionState.New;
+ if (string.Equals(value, "Enabled", StringComparison.InvariantCultureIgnoreCase)) return AdvancedThreatProtectionState.Enabled;
+ if (string.Equals(value, "Disabled", StringComparison.InvariantCultureIgnoreCase)) return AdvancedThreatProtectionState.Disabled;
+ throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown AdvancedThreatProtectionState value.");
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdvancedThreatProtectionState.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdvancedThreatProtectionState.cs
new file mode 100644
index 000000000000..799ff198cadc
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdvancedThreatProtectionState.cs
@@ -0,0 +1,20 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+namespace Azure.ResourceManager.Sql.Models
+{
+ /// Specifies the state of the Advanced Threat Protection, whether it is enabled or disabled or a state has not been applied yet on the specific database or server.
+ public enum AdvancedThreatProtectionState
+ {
+ /// New.
+ New,
+ /// Enabled.
+ Enabled,
+ /// Disabled.
+ Disabled
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionData.Serialization.cs
new file mode 100644
index 000000000000..c5730a71b1ad
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionData.Serialization.cs
@@ -0,0 +1,98 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Text.Json;
+using Azure.Core;
+using Azure.ResourceManager.Models;
+using Azure.ResourceManager.Sql.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ public partial class DatabaseAdvancedThreatProtectionData : IUtf8JsonSerializable
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
+ {
+ writer.WriteStartObject();
+ writer.WritePropertyName("properties");
+ writer.WriteStartObject();
+ if (Optional.IsDefined(State))
+ {
+ writer.WritePropertyName("state");
+ writer.WriteStringValue(State.Value.ToSerialString());
+ }
+ writer.WriteEndObject();
+ writer.WriteEndObject();
+ }
+
+ internal static DatabaseAdvancedThreatProtectionData DeserializeDatabaseAdvancedThreatProtectionData(JsonElement element)
+ {
+ ResourceIdentifier id = default;
+ string name = default;
+ ResourceType type = default;
+ SystemData systemData = default;
+ Optional state = default;
+ Optional creationTime = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("id"))
+ {
+ id = new ResourceIdentifier(property.Value.GetString());
+ continue;
+ }
+ if (property.NameEquals("name"))
+ {
+ name = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("type"))
+ {
+ type = new ResourceType(property.Value.GetString());
+ continue;
+ }
+ if (property.NameEquals("systemData"))
+ {
+ systemData = JsonSerializer.Deserialize(property.Value.ToString());
+ continue;
+ }
+ if (property.NameEquals("properties"))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ property.ThrowNonNullablePropertyIsNull();
+ continue;
+ }
+ foreach (var property0 in property.Value.EnumerateObject())
+ {
+ if (property0.NameEquals("state"))
+ {
+ if (property0.Value.ValueKind == JsonValueKind.Null)
+ {
+ property0.ThrowNonNullablePropertyIsNull();
+ continue;
+ }
+ state = property0.Value.GetString().ToAdvancedThreatProtectionState();
+ continue;
+ }
+ if (property0.NameEquals("creationTime"))
+ {
+ if (property0.Value.ValueKind == JsonValueKind.Null)
+ {
+ property0.ThrowNonNullablePropertyIsNull();
+ continue;
+ }
+ creationTime = property0.Value.GetDateTimeOffset("O");
+ continue;
+ }
+ }
+ continue;
+ }
+ }
+ return new DatabaseAdvancedThreatProtectionData(id, name, type, systemData, Optional.ToNullable(state), Optional.ToNullable(creationTime));
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionListResult.Serialization.cs
new file mode 100644
index 000000000000..360100c3fe03
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionListResult.Serialization.cs
@@ -0,0 +1,47 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+using Azure.ResourceManager.Sql;
+
+namespace Azure.ResourceManager.Sql.Models
+{
+ internal partial class DatabaseAdvancedThreatProtectionListResult
+ {
+ internal static DatabaseAdvancedThreatProtectionListResult DeserializeDatabaseAdvancedThreatProtectionListResult(JsonElement element)
+ {
+ Optional> value = default;
+ Optional nextLink = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("value"))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ property.ThrowNonNullablePropertyIsNull();
+ continue;
+ }
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(DatabaseAdvancedThreatProtectionData.DeserializeDatabaseAdvancedThreatProtectionData(item));
+ }
+ value = array;
+ continue;
+ }
+ if (property.NameEquals("nextLink"))
+ {
+ nextLink = property.Value.GetString();
+ continue;
+ }
+ }
+ return new DatabaseAdvancedThreatProtectionListResult(Optional.ToList(value), nextLink.Value);
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionListResult.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionListResult.cs
new file mode 100644
index 000000000000..3700bedf21a9
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionListResult.cs
@@ -0,0 +1,37 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Collections.Generic;
+using Azure.Core;
+using Azure.ResourceManager.Sql;
+
+namespace Azure.ResourceManager.Sql.Models
+{
+ /// A list of the database's Advanced Threat Protection configurations.
+ internal partial class DatabaseAdvancedThreatProtectionListResult
+ {
+ /// Initializes a new instance of DatabaseAdvancedThreatProtectionListResult.
+ internal DatabaseAdvancedThreatProtectionListResult()
+ {
+ Value = new ChangeTrackingList();
+ }
+
+ /// Initializes a new instance of DatabaseAdvancedThreatProtectionListResult.
+ /// Array of results.
+ /// Link to retrieve next page of results.
+ internal DatabaseAdvancedThreatProtectionListResult(IReadOnlyList value, string nextLink)
+ {
+ Value = value;
+ NextLink = nextLink;
+ }
+
+ /// Array of results.
+ public IReadOnlyList Value { get; }
+ /// Link to retrieve next page of results.
+ public string NextLink { get; }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerAdvancedThreatProtectionListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerAdvancedThreatProtectionListResult.Serialization.cs
new file mode 100644
index 000000000000..b8ff5cc2c4c8
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerAdvancedThreatProtectionListResult.Serialization.cs
@@ -0,0 +1,47 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+using Azure.ResourceManager.Sql;
+
+namespace Azure.ResourceManager.Sql.Models
+{
+ internal partial class LogicalServerAdvancedThreatProtectionListResult
+ {
+ internal static LogicalServerAdvancedThreatProtectionListResult DeserializeLogicalServerAdvancedThreatProtectionListResult(JsonElement element)
+ {
+ Optional> value = default;
+ Optional nextLink = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("value"))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ property.ThrowNonNullablePropertyIsNull();
+ continue;
+ }
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(ServerAdvancedThreatProtectionData.DeserializeServerAdvancedThreatProtectionData(item));
+ }
+ value = array;
+ continue;
+ }
+ if (property.NameEquals("nextLink"))
+ {
+ nextLink = property.Value.GetString();
+ continue;
+ }
+ }
+ return new LogicalServerAdvancedThreatProtectionListResult(Optional.ToList(value), nextLink.Value);
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerAdvancedThreatProtectionListResult.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerAdvancedThreatProtectionListResult.cs
new file mode 100644
index 000000000000..fb2d6d4d2b31
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerAdvancedThreatProtectionListResult.cs
@@ -0,0 +1,37 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Collections.Generic;
+using Azure.Core;
+using Azure.ResourceManager.Sql;
+
+namespace Azure.ResourceManager.Sql.Models
+{
+ /// A list of the server's Advanced Threat Protection configurations.
+ internal partial class LogicalServerAdvancedThreatProtectionListResult
+ {
+ /// Initializes a new instance of LogicalServerAdvancedThreatProtectionListResult.
+ internal LogicalServerAdvancedThreatProtectionListResult()
+ {
+ Value = new ChangeTrackingList();
+ }
+
+ /// Initializes a new instance of LogicalServerAdvancedThreatProtectionListResult.
+ /// Array of results.
+ /// Link to retrieve next page of results.
+ internal LogicalServerAdvancedThreatProtectionListResult(IReadOnlyList value, string nextLink)
+ {
+ Value = value;
+ NextLink = nextLink;
+ }
+
+ /// Array of results.
+ public IReadOnlyList Value { get; }
+ /// Link to retrieve next page of results.
+ public string NextLink { get; }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasAcquisition.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasAcquisition.Serialization.cs
new file mode 100644
index 000000000000..f6f504c74301
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasAcquisition.Serialization.cs
@@ -0,0 +1,23 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.ResourceManager.Sql.Models
+{
+ public partial class ManagedServerDnsAliasAcquisition : IUtf8JsonSerializable
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
+ {
+ writer.WriteStartObject();
+ writer.WritePropertyName("oldManagedServerDnsAliasResourceId");
+ writer.WriteStringValue(OldManagedServerDnsAliasResourceId);
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasAcquisition.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasAcquisition.cs
new file mode 100644
index 000000000000..ee2523711b52
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasAcquisition.cs
@@ -0,0 +1,31 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+
+namespace Azure.ResourceManager.Sql.Models
+{
+ /// A managed server DNS alias acquisition request.
+ public partial class ManagedServerDnsAliasAcquisition
+ {
+ /// Initializes a new instance of ManagedServerDnsAliasAcquisition.
+ /// The resource ID of the managed server DNS alias that will be acquired to point to this managed server instead.
+ /// is null.
+ public ManagedServerDnsAliasAcquisition(string oldManagedServerDnsAliasResourceId)
+ {
+ if (oldManagedServerDnsAliasResourceId == null)
+ {
+ throw new ArgumentNullException(nameof(oldManagedServerDnsAliasResourceId));
+ }
+
+ OldManagedServerDnsAliasResourceId = oldManagedServerDnsAliasResourceId;
+ }
+
+ /// The resource ID of the managed server DNS alias that will be acquired to point to this managed server instead.
+ public string OldManagedServerDnsAliasResourceId { get; }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasCreateOrUpdateContent.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasCreateOrUpdateContent.Serialization.cs
new file mode 100644
index 000000000000..93fe57797c41
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasCreateOrUpdateContent.Serialization.cs
@@ -0,0 +1,26 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.ResourceManager.Sql.Models
+{
+ public partial class ManagedServerDnsAliasCreateOrUpdateContent : IUtf8JsonSerializable
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
+ {
+ writer.WriteStartObject();
+ if (Optional.IsDefined(CreateDnsRecord))
+ {
+ writer.WritePropertyName("createDnsRecord");
+ writer.WriteBooleanValue(CreateDnsRecord.Value);
+ }
+ writer.WriteEndObject();
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasCreateOrUpdateContent.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasCreateOrUpdateContent.cs
new file mode 100644
index 000000000000..1494a7436989
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasCreateOrUpdateContent.cs
@@ -0,0 +1,21 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+namespace Azure.ResourceManager.Sql.Models
+{
+ /// A managed server dns alias creation request.
+ public partial class ManagedServerDnsAliasCreateOrUpdateContent
+ {
+ /// Initializes a new instance of ManagedServerDnsAliasCreateOrUpdateContent.
+ public ManagedServerDnsAliasCreateOrUpdateContent()
+ {
+ }
+
+ /// Whether or not DNS record should be created for this alias.
+ public bool? CreateDnsRecord { get; set; }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasData.Serialization.cs
new file mode 100644
index 000000000000..f08791494dd7
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasData.Serialization.cs
@@ -0,0 +1,81 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure.Core;
+using Azure.ResourceManager.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ public partial class ManagedServerDnsAliasData : IUtf8JsonSerializable
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
+ {
+ writer.WriteStartObject();
+ writer.WritePropertyName("properties");
+ writer.WriteStartObject();
+ writer.WriteEndObject();
+ writer.WriteEndObject();
+ }
+
+ internal static ManagedServerDnsAliasData DeserializeManagedServerDnsAliasData(JsonElement element)
+ {
+ ResourceIdentifier id = default;
+ string name = default;
+ ResourceType type = default;
+ SystemData systemData = default;
+ Optional azureDnsRecord = default;
+ Optional publicAzureDnsRecord = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("id"))
+ {
+ id = new ResourceIdentifier(property.Value.GetString());
+ continue;
+ }
+ if (property.NameEquals("name"))
+ {
+ name = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("type"))
+ {
+ type = new ResourceType(property.Value.GetString());
+ continue;
+ }
+ if (property.NameEquals("systemData"))
+ {
+ systemData = JsonSerializer.Deserialize(property.Value.ToString());
+ continue;
+ }
+ if (property.NameEquals("properties"))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ property.ThrowNonNullablePropertyIsNull();
+ continue;
+ }
+ foreach (var property0 in property.Value.EnumerateObject())
+ {
+ if (property0.NameEquals("azureDnsRecord"))
+ {
+ azureDnsRecord = property0.Value.GetString();
+ continue;
+ }
+ if (property0.NameEquals("publicAzureDnsRecord"))
+ {
+ publicAzureDnsRecord = property0.Value.GetString();
+ continue;
+ }
+ }
+ continue;
+ }
+ }
+ return new ManagedServerDnsAliasData(id, name, type, systemData, azureDnsRecord.Value, publicAzureDnsRecord.Value);
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasListResult.Serialization.cs
new file mode 100644
index 000000000000..50262c1084d8
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasListResult.Serialization.cs
@@ -0,0 +1,47 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure.Core;
+using Azure.ResourceManager.Sql;
+
+namespace Azure.ResourceManager.Sql.Models
+{
+ internal partial class ManagedServerDnsAliasListResult
+ {
+ internal static ManagedServerDnsAliasListResult DeserializeManagedServerDnsAliasListResult(JsonElement element)
+ {
+ Optional> value = default;
+ Optional nextLink = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("value"))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ property.ThrowNonNullablePropertyIsNull();
+ continue;
+ }
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(ManagedServerDnsAliasData.DeserializeManagedServerDnsAliasData(item));
+ }
+ value = array;
+ continue;
+ }
+ if (property.NameEquals("nextLink"))
+ {
+ nextLink = property.Value.GetString();
+ continue;
+ }
+ }
+ return new ManagedServerDnsAliasListResult(Optional.ToList(value), nextLink.Value);
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasListResult.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasListResult.cs
new file mode 100644
index 000000000000..82e6c13c2fb9
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedServerDnsAliasListResult.cs
@@ -0,0 +1,37 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Collections.Generic;
+using Azure.Core;
+using Azure.ResourceManager.Sql;
+
+namespace Azure.ResourceManager.Sql.Models
+{
+ /// A list of managed server DNS aliases.
+ internal partial class ManagedServerDnsAliasListResult
+ {
+ /// Initializes a new instance of ManagedServerDnsAliasListResult.
+ internal ManagedServerDnsAliasListResult()
+ {
+ Value = new ChangeTrackingList();
+ }
+
+ /// Initializes a new instance of ManagedServerDnsAliasListResult.
+ /// Array of results.
+ /// Link to retrieve next page of results.
+ internal ManagedServerDnsAliasListResult(IReadOnlyList value, string nextLink)
+ {
+ Value = value;
+ NextLink = nextLink;
+ }
+
+ /// Array of results.
+ public IReadOnlyList Value { get; }
+ /// Link to retrieve next page of results.
+ public string NextLink { get; }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerAdvancedThreatProtectionData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerAdvancedThreatProtectionData.Serialization.cs
new file mode 100644
index 000000000000..8dd8862c1195
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerAdvancedThreatProtectionData.Serialization.cs
@@ -0,0 +1,98 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Text.Json;
+using Azure.Core;
+using Azure.ResourceManager.Models;
+using Azure.ResourceManager.Sql.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ public partial class ServerAdvancedThreatProtectionData : IUtf8JsonSerializable
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
+ {
+ writer.WriteStartObject();
+ writer.WritePropertyName("properties");
+ writer.WriteStartObject();
+ if (Optional.IsDefined(State))
+ {
+ writer.WritePropertyName("state");
+ writer.WriteStringValue(State.Value.ToSerialString());
+ }
+ writer.WriteEndObject();
+ writer.WriteEndObject();
+ }
+
+ internal static ServerAdvancedThreatProtectionData DeserializeServerAdvancedThreatProtectionData(JsonElement element)
+ {
+ ResourceIdentifier id = default;
+ string name = default;
+ ResourceType type = default;
+ SystemData systemData = default;
+ Optional state = default;
+ Optional creationTime = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("id"))
+ {
+ id = new ResourceIdentifier(property.Value.GetString());
+ continue;
+ }
+ if (property.NameEquals("name"))
+ {
+ name = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("type"))
+ {
+ type = new ResourceType(property.Value.GetString());
+ continue;
+ }
+ if (property.NameEquals("systemData"))
+ {
+ systemData = JsonSerializer.Deserialize(property.Value.ToString());
+ continue;
+ }
+ if (property.NameEquals("properties"))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ property.ThrowNonNullablePropertyIsNull();
+ continue;
+ }
+ foreach (var property0 in property.Value.EnumerateObject())
+ {
+ if (property0.NameEquals("state"))
+ {
+ if (property0.Value.ValueKind == JsonValueKind.Null)
+ {
+ property0.ThrowNonNullablePropertyIsNull();
+ continue;
+ }
+ state = property0.Value.GetString().ToAdvancedThreatProtectionState();
+ continue;
+ }
+ if (property0.NameEquals("creationTime"))
+ {
+ if (property0.Value.ValueKind == JsonValueKind.Null)
+ {
+ property0.ThrowNonNullablePropertyIsNull();
+ continue;
+ }
+ creationTime = property0.Value.GetDateTimeOffset("O");
+ continue;
+ }
+ }
+ continue;
+ }
+ }
+ return new ServerAdvancedThreatProtectionData(id, name, type, systemData, Optional.ToNullable(state), Optional.ToNullable(creationTime));
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/DatabaseAdvancedThreatProtectionSettingsRestOperations.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/DatabaseAdvancedThreatProtectionSettingsRestOperations.cs
new file mode 100644
index 000000000000..59f7547cfda8
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/DatabaseAdvancedThreatProtectionSettingsRestOperations.cs
@@ -0,0 +1,395 @@
+// 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;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager.Sql.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ internal partial class DatabaseAdvancedThreatProtectionSettingsRestOperations
+ {
+ private readonly TelemetryDetails _userAgent;
+ private readonly HttpPipeline _pipeline;
+ private readonly Uri _endpoint;
+ private readonly string _apiVersion;
+
+ /// Initializes a new instance of DatabaseAdvancedThreatProtectionSettingsRestOperations.
+ /// The HTTP pipeline for sending and receiving REST requests and responses.
+ /// The application id to use for user agent.
+ /// server parameter.
+ /// Api Version.
+ /// or is null.
+ public DatabaseAdvancedThreatProtectionSettingsRestOperations(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 ?? "2021-11-01-preview";
+ _userAgent = new TelemetryDetails(GetType().Assembly, applicationId);
+ }
+
+ internal HttpMessage CreateListByDatabaseRequest(string subscriptionId, string resourceGroupName, string serverName, string databaseName)
+ {
+ 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.Sql/servers/", false);
+ uri.AppendPath(serverName, true);
+ uri.AppendPath("/databases/", false);
+ uri.AppendPath(databaseName, true);
+ uri.AppendPath("/advancedThreatProtectionSettings", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ _userAgent.Apply(message);
+ return message;
+ }
+
+ /// Gets a list of database's Advanced Threat Protection states.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The name of the database.
+ /// The cancellation token to use.
+ /// , , or is null.
+ /// , , or is an empty string, and was expected to be non-empty.
+ public async Task> ListByDatabaseAsync(string subscriptionId, string resourceGroupName, string serverName, string databaseName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+ Argument.AssertNotNullOrEmpty(databaseName, nameof(databaseName));
+
+ using var message = CreateListByDatabaseRequest(subscriptionId, resourceGroupName, serverName, databaseName);
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ DatabaseAdvancedThreatProtectionListResult value = default;
+ using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
+ value = DatabaseAdvancedThreatProtectionListResult.DeserializeDatabaseAdvancedThreatProtectionListResult(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ /// Gets a list of database's Advanced Threat Protection states.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The name of the database.
+ /// The cancellation token to use.
+ /// , , or is null.
+ /// , , or is an empty string, and was expected to be non-empty.
+ public Response ListByDatabase(string subscriptionId, string resourceGroupName, string serverName, string databaseName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+ Argument.AssertNotNullOrEmpty(databaseName, nameof(databaseName));
+
+ using var message = CreateListByDatabaseRequest(subscriptionId, resourceGroupName, serverName, databaseName);
+ _pipeline.Send(message, cancellationToken);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ DatabaseAdvancedThreatProtectionListResult value = default;
+ using var document = JsonDocument.Parse(message.Response.ContentStream);
+ value = DatabaseAdvancedThreatProtectionListResult.DeserializeDatabaseAdvancedThreatProtectionListResult(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string serverName, string databaseName, AdvancedThreatProtectionName advancedThreatProtectionName)
+ {
+ 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.Sql/servers/", false);
+ uri.AppendPath(serverName, true);
+ uri.AppendPath("/databases/", false);
+ uri.AppendPath(databaseName, true);
+ uri.AppendPath("/advancedThreatProtectionSettings/", false);
+ uri.AppendPath(advancedThreatProtectionName.ToString(), true);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ _userAgent.Apply(message);
+ return message;
+ }
+
+ /// Gets a database's Advanced Threat Protection state.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The name of the database.
+ /// The name of the Advanced Threat Protection state.
+ /// 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 serverName, string databaseName, AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+ Argument.AssertNotNullOrEmpty(databaseName, nameof(databaseName));
+
+ using var message = CreateGetRequest(subscriptionId, resourceGroupName, serverName, databaseName, advancedThreatProtectionName);
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ DatabaseAdvancedThreatProtectionData value = default;
+ using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
+ value = DatabaseAdvancedThreatProtectionData.DeserializeDatabaseAdvancedThreatProtectionData(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ case 404:
+ return Response.FromValue((DatabaseAdvancedThreatProtectionData)null, message.Response);
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ /// Gets a database's Advanced Threat Protection state.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The name of the database.
+ /// The name of the Advanced Threat Protection state.
+ /// 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 serverName, string databaseName, AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+ Argument.AssertNotNullOrEmpty(databaseName, nameof(databaseName));
+
+ using var message = CreateGetRequest(subscriptionId, resourceGroupName, serverName, databaseName, advancedThreatProtectionName);
+ _pipeline.Send(message, cancellationToken);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ DatabaseAdvancedThreatProtectionData value = default;
+ using var document = JsonDocument.Parse(message.Response.ContentStream);
+ value = DatabaseAdvancedThreatProtectionData.DeserializeDatabaseAdvancedThreatProtectionData(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ case 404:
+ return Response.FromValue((DatabaseAdvancedThreatProtectionData)null, message.Response);
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string serverName, string databaseName, AdvancedThreatProtectionName advancedThreatProtectionName, DatabaseAdvancedThreatProtectionData 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.Sql/servers/", false);
+ uri.AppendPath(serverName, true);
+ uri.AppendPath("/databases/", false);
+ uri.AppendPath(databaseName, true);
+ uri.AppendPath("/advancedThreatProtectionSettings/", false);
+ uri.AppendPath(advancedThreatProtectionName.ToString(), 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);
+ request.Content = content;
+ _userAgent.Apply(message);
+ return message;
+ }
+
+ /// Creates or updates a database's Advanced Threat Protection state.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The name of the database.
+ /// The name of the Advanced Threat Protection state.
+ /// The database Advanced Threat Protection state.
+ /// 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 serverName, string databaseName, AdvancedThreatProtectionName advancedThreatProtectionName, DatabaseAdvancedThreatProtectionData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+ Argument.AssertNotNullOrEmpty(databaseName, nameof(databaseName));
+ Argument.AssertNotNull(data, nameof(data));
+
+ using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, serverName, databaseName, advancedThreatProtectionName, data);
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
+ switch (message.Response.Status)
+ {
+ case 200:
+ case 201:
+ {
+ DatabaseAdvancedThreatProtectionData value = default;
+ using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
+ value = DatabaseAdvancedThreatProtectionData.DeserializeDatabaseAdvancedThreatProtectionData(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ /// Creates or updates a database's Advanced Threat Protection state.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The name of the database.
+ /// The name of the Advanced Threat Protection state.
+ /// The database Advanced Threat Protection state.
+ /// 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 serverName, string databaseName, AdvancedThreatProtectionName advancedThreatProtectionName, DatabaseAdvancedThreatProtectionData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+ Argument.AssertNotNullOrEmpty(databaseName, nameof(databaseName));
+ Argument.AssertNotNull(data, nameof(data));
+
+ using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, serverName, databaseName, advancedThreatProtectionName, data);
+ _pipeline.Send(message, cancellationToken);
+ switch (message.Response.Status)
+ {
+ case 200:
+ case 201:
+ {
+ DatabaseAdvancedThreatProtectionData value = default;
+ using var document = JsonDocument.Parse(message.Response.ContentStream);
+ value = DatabaseAdvancedThreatProtectionData.DeserializeDatabaseAdvancedThreatProtectionData(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ internal HttpMessage CreateListByDatabaseNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string serverName, string databaseName)
+ {
+ 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;
+ }
+
+ /// Gets a list of database's Advanced Threat Protection states.
+ /// The URL to the next page of results.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The name of the database.
+ /// The cancellation token to use.
+ /// , , , or is null.
+ /// , , or is an empty string, and was expected to be non-empty.
+ public async Task> ListByDatabaseNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string serverName, string databaseName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(nextLink, nameof(nextLink));
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+ Argument.AssertNotNullOrEmpty(databaseName, nameof(databaseName));
+
+ using var message = CreateListByDatabaseNextPageRequest(nextLink, subscriptionId, resourceGroupName, serverName, databaseName);
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ DatabaseAdvancedThreatProtectionListResult value = default;
+ using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
+ value = DatabaseAdvancedThreatProtectionListResult.DeserializeDatabaseAdvancedThreatProtectionListResult(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ /// Gets a list of database's Advanced Threat Protection states.
+ /// The URL to the next page of results.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The name of the database.
+ /// The cancellation token to use.
+ /// , , , or is null.
+ /// , , or is an empty string, and was expected to be non-empty.
+ public Response ListByDatabaseNextPage(string nextLink, string subscriptionId, string resourceGroupName, string serverName, string databaseName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(nextLink, nameof(nextLink));
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+ Argument.AssertNotNullOrEmpty(databaseName, nameof(databaseName));
+
+ using var message = CreateListByDatabaseNextPageRequest(nextLink, subscriptionId, resourceGroupName, serverName, databaseName);
+ _pipeline.Send(message, cancellationToken);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ DatabaseAdvancedThreatProtectionListResult value = default;
+ using var document = JsonDocument.Parse(message.Response.ContentStream);
+ value = DatabaseAdvancedThreatProtectionListResult.DeserializeDatabaseAdvancedThreatProtectionListResult(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/ManagedServerDnsAliasesRestOperations.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/ManagedServerDnsAliasesRestOperations.cs
new file mode 100644
index 000000000000..6fdf5d720d84
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/ManagedServerDnsAliasesRestOperations.cs
@@ -0,0 +1,531 @@
+// 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;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager.Sql.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ internal partial class ManagedServerDnsAliasesRestOperations
+ {
+ private readonly TelemetryDetails _userAgent;
+ private readonly HttpPipeline _pipeline;
+ private readonly Uri _endpoint;
+ private readonly string _apiVersion;
+
+ /// Initializes a new instance of ManagedServerDnsAliasesRestOperations.
+ /// The HTTP pipeline for sending and receiving REST requests and responses.
+ /// The application id to use for user agent.
+ /// server parameter.
+ /// Api Version.
+ /// or is null.
+ public ManagedServerDnsAliasesRestOperations(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 ?? "2021-11-01-preview";
+ _userAgent = new TelemetryDetails(GetType().Assembly, applicationId);
+ }
+
+ internal HttpMessage CreateListByManagedInstanceRequest(string subscriptionId, string resourceGroupName, string managedInstanceName)
+ {
+ 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.Sql/managedInstances/", false);
+ uri.AppendPath(managedInstanceName, true);
+ uri.AppendPath("/dnsAliases", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ _userAgent.Apply(message);
+ return message;
+ }
+
+ /// Gets a list of managed server DNS aliases for a managed server.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the managed instance.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// , or is an empty string, and was expected to be non-empty.
+ public async Task> ListByManagedInstanceAsync(string subscriptionId, string resourceGroupName, string managedInstanceName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(managedInstanceName, nameof(managedInstanceName));
+
+ using var message = CreateListByManagedInstanceRequest(subscriptionId, resourceGroupName, managedInstanceName);
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ ManagedServerDnsAliasListResult value = default;
+ using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
+ value = ManagedServerDnsAliasListResult.DeserializeManagedServerDnsAliasListResult(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ /// Gets a list of managed server DNS aliases for a managed server.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the managed instance.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// , or is an empty string, and was expected to be non-empty.
+ public Response ListByManagedInstance(string subscriptionId, string resourceGroupName, string managedInstanceName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(managedInstanceName, nameof(managedInstanceName));
+
+ using var message = CreateListByManagedInstanceRequest(subscriptionId, resourceGroupName, managedInstanceName);
+ _pipeline.Send(message, cancellationToken);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ ManagedServerDnsAliasListResult value = default;
+ using var document = JsonDocument.Parse(message.Response.ContentStream);
+ value = ManagedServerDnsAliasListResult.DeserializeManagedServerDnsAliasListResult(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string managedInstanceName, string dnsAliasName)
+ {
+ 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.Sql/managedInstances/", false);
+ uri.AppendPath(managedInstanceName, true);
+ uri.AppendPath("/dnsAliases/", false);
+ uri.AppendPath(dnsAliasName, true);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ _userAgent.Apply(message);
+ return message;
+ }
+
+ /// Gets a server DNS alias.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the managed instance.
+ /// The String to use.
+ /// 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 managedInstanceName, string dnsAliasName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(managedInstanceName, nameof(managedInstanceName));
+ Argument.AssertNotNullOrEmpty(dnsAliasName, nameof(dnsAliasName));
+
+ using var message = CreateGetRequest(subscriptionId, resourceGroupName, managedInstanceName, dnsAliasName);
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ ManagedServerDnsAliasData value = default;
+ using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
+ value = ManagedServerDnsAliasData.DeserializeManagedServerDnsAliasData(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ case 404:
+ return Response.FromValue((ManagedServerDnsAliasData)null, message.Response);
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ /// Gets a server DNS alias.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the managed instance.
+ /// The String to use.
+ /// 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 managedInstanceName, string dnsAliasName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(managedInstanceName, nameof(managedInstanceName));
+ Argument.AssertNotNullOrEmpty(dnsAliasName, nameof(dnsAliasName));
+
+ using var message = CreateGetRequest(subscriptionId, resourceGroupName, managedInstanceName, dnsAliasName);
+ _pipeline.Send(message, cancellationToken);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ ManagedServerDnsAliasData value = default;
+ using var document = JsonDocument.Parse(message.Response.ContentStream);
+ value = ManagedServerDnsAliasData.DeserializeManagedServerDnsAliasData(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ case 404:
+ return Response.FromValue((ManagedServerDnsAliasData)null, message.Response);
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string managedInstanceName, string dnsAliasName, ManagedServerDnsAliasCreateOrUpdateContent content)
+ {
+ 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.Sql/managedInstances/", false);
+ uri.AppendPath(managedInstanceName, true);
+ uri.AppendPath("/dnsAliases/", false);
+ uri.AppendPath(dnsAliasName, true);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Content-Type", "application/json");
+ var content0 = new Utf8JsonRequestContent();
+ content0.JsonWriter.WriteObjectValue(content);
+ request.Content = content0;
+ _userAgent.Apply(message);
+ return message;
+ }
+
+ /// Creates a managed server DNS alias.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the managed instance.
+ /// The String to use.
+ /// The ManagedServerDnsAliasCreateOrUpdateContent to use.
+ /// 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 managedInstanceName, string dnsAliasName, ManagedServerDnsAliasCreateOrUpdateContent content, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(managedInstanceName, nameof(managedInstanceName));
+ Argument.AssertNotNullOrEmpty(dnsAliasName, nameof(dnsAliasName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, managedInstanceName, dnsAliasName, content);
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
+ switch (message.Response.Status)
+ {
+ case 200:
+ case 201:
+ case 202:
+ return message.Response;
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ /// Creates a managed server DNS alias.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the managed instance.
+ /// The String to use.
+ /// The ManagedServerDnsAliasCreateOrUpdateContent to use.
+ /// 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 managedInstanceName, string dnsAliasName, ManagedServerDnsAliasCreateOrUpdateContent content, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(managedInstanceName, nameof(managedInstanceName));
+ Argument.AssertNotNullOrEmpty(dnsAliasName, nameof(dnsAliasName));
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, managedInstanceName, dnsAliasName, content);
+ _pipeline.Send(message, cancellationToken);
+ switch (message.Response.Status)
+ {
+ case 200:
+ case 201:
+ case 202:
+ return message.Response;
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string managedInstanceName, string dnsAliasName)
+ {
+ 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.Sql/managedInstances/", false);
+ uri.AppendPath(managedInstanceName, true);
+ uri.AppendPath("/dnsAliases/", false);
+ uri.AppendPath(dnsAliasName, true);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ _userAgent.Apply(message);
+ return message;
+ }
+
+ /// Deletes the managed server DNS alias with the given name.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the managed instance.
+ /// The String to use.
+ /// 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 managedInstanceName, string dnsAliasName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(managedInstanceName, nameof(managedInstanceName));
+ Argument.AssertNotNullOrEmpty(dnsAliasName, nameof(dnsAliasName));
+
+ using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, managedInstanceName, dnsAliasName);
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
+ switch (message.Response.Status)
+ {
+ case 200:
+ case 202:
+ case 204:
+ return message.Response;
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ /// Deletes the managed server DNS alias with the given name.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the managed instance.
+ /// The String to use.
+ /// 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 managedInstanceName, string dnsAliasName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(managedInstanceName, nameof(managedInstanceName));
+ Argument.AssertNotNullOrEmpty(dnsAliasName, nameof(dnsAliasName));
+
+ using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, managedInstanceName, dnsAliasName);
+ _pipeline.Send(message, cancellationToken);
+ switch (message.Response.Status)
+ {
+ case 200:
+ case 202:
+ case 204:
+ return message.Response;
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ internal HttpMessage CreateAcquireRequest(string subscriptionId, string resourceGroupName, string managedInstanceName, string dnsAliasName, ManagedServerDnsAliasAcquisition managedServerDnsAliasAcquisition)
+ {
+ 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.Sql/managedInstances/", false);
+ uri.AppendPath(managedInstanceName, true);
+ uri.AppendPath("/dnsAliases/", false);
+ uri.AppendPath(dnsAliasName, true);
+ uri.AppendPath("/acquire", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Content-Type", "application/json");
+ var content0 = new Utf8JsonRequestContent();
+ content0.JsonWriter.WriteObjectValue(managedServerDnsAliasAcquisition);
+ request.Content = content0;
+ _userAgent.Apply(message);
+ return message;
+ }
+
+ /// Acquires managed server DNS alias from another managed server.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the managed instance.
+ /// The String to use.
+ /// The ManagedServerDnsAliasAcquisition to use.
+ /// The cancellation token to use.
+ /// , , , or is null.
+ /// , , or is an empty string, and was expected to be non-empty.
+ public async Task AcquireAsync(string subscriptionId, string resourceGroupName, string managedInstanceName, string dnsAliasName, ManagedServerDnsAliasAcquisition managedServerDnsAliasAcquisition, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(managedInstanceName, nameof(managedInstanceName));
+ Argument.AssertNotNullOrEmpty(dnsAliasName, nameof(dnsAliasName));
+ Argument.AssertNotNull(managedServerDnsAliasAcquisition, nameof(managedServerDnsAliasAcquisition));
+
+ using var message = CreateAcquireRequest(subscriptionId, resourceGroupName, managedInstanceName, dnsAliasName, managedServerDnsAliasAcquisition);
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
+ switch (message.Response.Status)
+ {
+ case 200:
+ case 202:
+ return message.Response;
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ /// Acquires managed server DNS alias from another managed server.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the managed instance.
+ /// The String to use.
+ /// The ManagedServerDnsAliasAcquisition to use.
+ /// The cancellation token to use.
+ /// , , , or is null.
+ /// , , or is an empty string, and was expected to be non-empty.
+ public Response Acquire(string subscriptionId, string resourceGroupName, string managedInstanceName, string dnsAliasName, ManagedServerDnsAliasAcquisition managedServerDnsAliasAcquisition, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(managedInstanceName, nameof(managedInstanceName));
+ Argument.AssertNotNullOrEmpty(dnsAliasName, nameof(dnsAliasName));
+ Argument.AssertNotNull(managedServerDnsAliasAcquisition, nameof(managedServerDnsAliasAcquisition));
+
+ using var message = CreateAcquireRequest(subscriptionId, resourceGroupName, managedInstanceName, dnsAliasName, managedServerDnsAliasAcquisition);
+ _pipeline.Send(message, cancellationToken);
+ switch (message.Response.Status)
+ {
+ case 200:
+ case 202:
+ return message.Response;
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ internal HttpMessage CreateListByManagedInstanceNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string managedInstanceName)
+ {
+ 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;
+ }
+
+ /// Gets a list of managed server DNS aliases for a managed server.
+ /// The URL to the next page of results.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the managed instance.
+ /// The cancellation token to use.
+ /// , , or is null.
+ /// , or is an empty string, and was expected to be non-empty.
+ public async Task> ListByManagedInstanceNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string managedInstanceName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(nextLink, nameof(nextLink));
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(managedInstanceName, nameof(managedInstanceName));
+
+ using var message = CreateListByManagedInstanceNextPageRequest(nextLink, subscriptionId, resourceGroupName, managedInstanceName);
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ ManagedServerDnsAliasListResult value = default;
+ using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
+ value = ManagedServerDnsAliasListResult.DeserializeManagedServerDnsAliasListResult(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ /// Gets a list of managed server DNS aliases for a managed server.
+ /// The URL to the next page of results.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the managed instance.
+ /// The cancellation token to use.
+ /// , , or is null.
+ /// , or is an empty string, and was expected to be non-empty.
+ public Response ListByManagedInstanceNextPage(string nextLink, string subscriptionId, string resourceGroupName, string managedInstanceName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(nextLink, nameof(nextLink));
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(managedInstanceName, nameof(managedInstanceName));
+
+ using var message = CreateListByManagedInstanceNextPageRequest(nextLink, subscriptionId, resourceGroupName, managedInstanceName);
+ _pipeline.Send(message, cancellationToken);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ ManagedServerDnsAliasListResult value = default;
+ using var document = JsonDocument.Parse(message.Response.ContentStream);
+ value = ManagedServerDnsAliasListResult.DeserializeManagedServerDnsAliasListResult(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/ServerAdvancedThreatProtectionSettingsRestOperations.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/ServerAdvancedThreatProtectionSettingsRestOperations.cs
new file mode 100644
index 000000000000..9509e5dc7713
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/ServerAdvancedThreatProtectionSettingsRestOperations.cs
@@ -0,0 +1,363 @@
+// 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;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager.Sql.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ internal partial class ServerAdvancedThreatProtectionSettingsRestOperations
+ {
+ private readonly TelemetryDetails _userAgent;
+ private readonly HttpPipeline _pipeline;
+ private readonly Uri _endpoint;
+ private readonly string _apiVersion;
+
+ /// Initializes a new instance of ServerAdvancedThreatProtectionSettingsRestOperations.
+ /// The HTTP pipeline for sending and receiving REST requests and responses.
+ /// The application id to use for user agent.
+ /// server parameter.
+ /// Api Version.
+ /// or is null.
+ public ServerAdvancedThreatProtectionSettingsRestOperations(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 ?? "2021-11-01-preview";
+ _userAgent = new TelemetryDetails(GetType().Assembly, applicationId);
+ }
+
+ internal HttpMessage CreateListByServerRequest(string subscriptionId, string resourceGroupName, string serverName)
+ {
+ 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.Sql/servers/", false);
+ uri.AppendPath(serverName, true);
+ uri.AppendPath("/advancedThreatProtectionSettings", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ _userAgent.Apply(message);
+ return message;
+ }
+
+ /// Get a list of the server's Advanced Threat Protection states.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// , or is an empty string, and was expected to be non-empty.
+ public async Task> ListByServerAsync(string subscriptionId, string resourceGroupName, string serverName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+
+ using var message = CreateListByServerRequest(subscriptionId, resourceGroupName, serverName);
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ LogicalServerAdvancedThreatProtectionListResult value = default;
+ using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
+ value = LogicalServerAdvancedThreatProtectionListResult.DeserializeLogicalServerAdvancedThreatProtectionListResult(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ /// Get a list of the server's Advanced Threat Protection states.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The cancellation token to use.
+ /// , or is null.
+ /// , or is an empty string, and was expected to be non-empty.
+ public Response ListByServer(string subscriptionId, string resourceGroupName, string serverName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+
+ using var message = CreateListByServerRequest(subscriptionId, resourceGroupName, serverName);
+ _pipeline.Send(message, cancellationToken);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ LogicalServerAdvancedThreatProtectionListResult value = default;
+ using var document = JsonDocument.Parse(message.Response.ContentStream);
+ value = LogicalServerAdvancedThreatProtectionListResult.DeserializeLogicalServerAdvancedThreatProtectionListResult(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string serverName, AdvancedThreatProtectionName advancedThreatProtectionName)
+ {
+ 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.Sql/servers/", false);
+ uri.AppendPath(serverName, true);
+ uri.AppendPath("/advancedThreatProtectionSettings/", false);
+ uri.AppendPath(advancedThreatProtectionName.ToString(), true);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ _userAgent.Apply(message);
+ return message;
+ }
+
+ /// Get a server's Advanced Threat Protection state.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The name of the Advanced Threat Protection state.
+ /// 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 serverName, AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+
+ using var message = CreateGetRequest(subscriptionId, resourceGroupName, serverName, advancedThreatProtectionName);
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ ServerAdvancedThreatProtectionData value = default;
+ using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
+ value = ServerAdvancedThreatProtectionData.DeserializeServerAdvancedThreatProtectionData(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ case 404:
+ return Response.FromValue((ServerAdvancedThreatProtectionData)null, message.Response);
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ /// Get a server's Advanced Threat Protection state.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The name of the Advanced Threat Protection state.
+ /// 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 serverName, AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+
+ using var message = CreateGetRequest(subscriptionId, resourceGroupName, serverName, advancedThreatProtectionName);
+ _pipeline.Send(message, cancellationToken);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ ServerAdvancedThreatProtectionData value = default;
+ using var document = JsonDocument.Parse(message.Response.ContentStream);
+ value = ServerAdvancedThreatProtectionData.DeserializeServerAdvancedThreatProtectionData(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ case 404:
+ return Response.FromValue((ServerAdvancedThreatProtectionData)null, message.Response);
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string serverName, AdvancedThreatProtectionName advancedThreatProtectionName, ServerAdvancedThreatProtectionData 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.Sql/servers/", false);
+ uri.AppendPath(serverName, true);
+ uri.AppendPath("/advancedThreatProtectionSettings/", false);
+ uri.AppendPath(advancedThreatProtectionName.ToString(), 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);
+ request.Content = content;
+ _userAgent.Apply(message);
+ return message;
+ }
+
+ /// Creates or updates an Advanced Threat Protection state.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The name of the Advanced Threat Protection state.
+ /// The server Advanced Threat Protection state.
+ /// 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 serverName, AdvancedThreatProtectionName advancedThreatProtectionName, ServerAdvancedThreatProtectionData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+ Argument.AssertNotNull(data, nameof(data));
+
+ using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, serverName, advancedThreatProtectionName, data);
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
+ switch (message.Response.Status)
+ {
+ case 200:
+ case 202:
+ return message.Response;
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ /// Creates or updates an Advanced Threat Protection state.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The name of the Advanced Threat Protection state.
+ /// The server Advanced Threat Protection state.
+ /// 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 serverName, AdvancedThreatProtectionName advancedThreatProtectionName, ServerAdvancedThreatProtectionData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+ Argument.AssertNotNull(data, nameof(data));
+
+ using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, serverName, advancedThreatProtectionName, data);
+ _pipeline.Send(message, cancellationToken);
+ switch (message.Response.Status)
+ {
+ case 200:
+ case 202:
+ return message.Response;
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ internal HttpMessage CreateListByServerNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string serverName)
+ {
+ 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;
+ }
+
+ /// Get a list of the server's Advanced Threat Protection states.
+ /// The URL to the next page of results.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The cancellation token to use.
+ /// , , or is null.
+ /// , or is an empty string, and was expected to be non-empty.
+ public async Task> ListByServerNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string serverName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(nextLink, nameof(nextLink));
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+
+ using var message = CreateListByServerNextPageRequest(nextLink, subscriptionId, resourceGroupName, serverName);
+ await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ LogicalServerAdvancedThreatProtectionListResult value = default;
+ using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);
+ value = LogicalServerAdvancedThreatProtectionListResult.DeserializeLogicalServerAdvancedThreatProtectionListResult(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+
+ /// Get a list of the server's Advanced Threat Protection states.
+ /// The URL to the next page of results.
+ /// The subscription ID that identifies an Azure subscription.
+ /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
+ /// The name of the server.
+ /// The cancellation token to use.
+ /// , , or is null.
+ /// , or is an empty string, and was expected to be non-empty.
+ public Response ListByServerNextPage(string nextLink, string subscriptionId, string resourceGroupName, string serverName, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(nextLink, nameof(nextLink));
+ Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
+ Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
+ Argument.AssertNotNullOrEmpty(serverName, nameof(serverName));
+
+ using var message = CreateListByServerNextPageRequest(nextLink, subscriptionId, resourceGroupName, serverName);
+ _pipeline.Send(message, cancellationToken);
+ switch (message.Response.Status)
+ {
+ case 200:
+ {
+ LogicalServerAdvancedThreatProtectionListResult value = default;
+ using var document = JsonDocument.Parse(message.Response.ContentStream);
+ value = LogicalServerAdvancedThreatProtectionListResult.DeserializeLogicalServerAdvancedThreatProtectionListResult(document.RootElement);
+ return Response.FromValue(value, message.Response);
+ }
+ default:
+ throw new RequestFailedException(message.Response);
+ }
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionCollection.cs
new file mode 100644
index 000000000000..4a951af5b130
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionCollection.cs
@@ -0,0 +1,314 @@
+// 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.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Azure;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager;
+using Azure.ResourceManager.Sql.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ ///
+ /// 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 GetServerAdvancedThreatProtections method from an instance of .
+ ///
+ public partial class ServerAdvancedThreatProtectionCollection : ArmCollection, IEnumerable, IAsyncEnumerable
+ {
+ private readonly ClientDiagnostics _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics;
+ private readonly ServerAdvancedThreatProtectionSettingsRestOperations _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient;
+
+ /// Initializes a new instance of the class for mocking.
+ protected ServerAdvancedThreatProtectionCollection()
+ {
+ }
+
+ /// 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 ServerAdvancedThreatProtectionCollection(ArmClient client, ResourceIdentifier id) : base(client, id)
+ {
+ _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sql", ServerAdvancedThreatProtectionResource.ResourceType.Namespace, Diagnostics);
+ TryGetApiVersion(ServerAdvancedThreatProtectionResource.ResourceType, out string serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsApiVersion);
+ _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient = new ServerAdvancedThreatProtectionSettingsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsApiVersion);
+#if DEBUG
+ ValidateResourceId(Id);
+#endif
+ }
+
+ internal static void ValidateResourceId(ResourceIdentifier id)
+ {
+ if (id.ResourceType != SqlServerResource.ResourceType)
+ throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, SqlServerResource.ResourceType), nameof(id));
+ }
+
+ ///
+ /// Creates or updates an Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: ServerAdvancedThreatProtectionSettings_CreateOrUpdate
+ ///
+ /// 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 name of the Advanced Threat Protection state.
+ /// The server Advanced Threat Protection state.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, AdvancedThreatProtectionName advancedThreatProtectionName, ServerAdvancedThreatProtectionData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(data, nameof(data));
+
+ using var scope = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("ServerAdvancedThreatProtectionCollection.CreateOrUpdate");
+ scope.Start();
+ try
+ {
+ var response = await _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, advancedThreatProtectionName, data, cancellationToken).ConfigureAwait(false);
+ var operation = new SqlArmOperation(new ServerAdvancedThreatProtectionOperationSource(Client), _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics, Pipeline, _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, advancedThreatProtectionName, data).Request, response, OperationFinalStateVia.Location);
+ if (waitUntil == WaitUntil.Completed)
+ await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Creates or updates an Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: ServerAdvancedThreatProtectionSettings_CreateOrUpdate
+ ///
+ /// 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 name of the Advanced Threat Protection state.
+ /// The server Advanced Threat Protection state.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, AdvancedThreatProtectionName advancedThreatProtectionName, ServerAdvancedThreatProtectionData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(data, nameof(data));
+
+ using var scope = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("ServerAdvancedThreatProtectionCollection.CreateOrUpdate");
+ scope.Start();
+ try
+ {
+ var response = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, advancedThreatProtectionName, data, cancellationToken);
+ var operation = new SqlArmOperation(new ServerAdvancedThreatProtectionOperationSource(Client), _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics, Pipeline, _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, advancedThreatProtectionName, data).Request, response, OperationFinalStateVia.Location);
+ if (waitUntil == WaitUntil.Completed)
+ operation.WaitForCompletion(cancellationToken);
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Get a server's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: ServerAdvancedThreatProtectionSettings_Get
+ ///
+ /// The name of the Advanced Threat Protection state.
+ /// The cancellation token to use.
+ public virtual async Task> GetAsync(AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ using var scope = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("ServerAdvancedThreatProtectionCollection.Get");
+ scope.Start();
+ try
+ {
+ var response = await _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, advancedThreatProtectionName, cancellationToken).ConfigureAwait(false);
+ if (response.Value == null)
+ throw new RequestFailedException(response.GetRawResponse());
+ return Response.FromValue(new ServerAdvancedThreatProtectionResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Get a server's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: ServerAdvancedThreatProtectionSettings_Get
+ ///
+ /// The name of the Advanced Threat Protection state.
+ /// The cancellation token to use.
+ public virtual Response Get(AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ using var scope = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("ServerAdvancedThreatProtectionCollection.Get");
+ scope.Start();
+ try
+ {
+ var response = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, advancedThreatProtectionName, cancellationToken);
+ if (response.Value == null)
+ throw new RequestFailedException(response.GetRawResponse());
+ return Response.FromValue(new ServerAdvancedThreatProtectionResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Get a list of the server's Advanced Threat Protection states.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings
+ /// Operation Id: ServerAdvancedThreatProtectionSettings_ListByServer
+ ///
+ /// 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)
+ {
+ async Task> FirstPageFunc(int? pageSizeHint)
+ {
+ using var scope = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("ServerAdvancedThreatProtectionCollection.GetAll");
+ scope.Start();
+ try
+ {
+ var response = await _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.ListByServerAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Page.FromValues(response.Value.Value.Select(value => new ServerAdvancedThreatProtectionResource(Client, value)), response.Value.NextLink, response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ async Task> NextPageFunc(string nextLink, int? pageSizeHint)
+ {
+ using var scope = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("ServerAdvancedThreatProtectionCollection.GetAll");
+ scope.Start();
+ try
+ {
+ var response = await _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.ListByServerNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken).ConfigureAwait(false);
+ return Page.FromValues(response.Value.Value.Select(value => new ServerAdvancedThreatProtectionResource(Client, value)), response.Value.NextLink, response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
+ }
+
+ ///
+ /// Get a list of the server's Advanced Threat Protection states.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings
+ /// Operation Id: ServerAdvancedThreatProtectionSettings_ListByServer
+ ///
+ /// The cancellation token to use.
+ /// A collection of that may take multiple service requests to iterate over.
+ public virtual Pageable GetAll(CancellationToken cancellationToken = default)
+ {
+ Page FirstPageFunc(int? pageSizeHint)
+ {
+ using var scope = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("ServerAdvancedThreatProtectionCollection.GetAll");
+ scope.Start();
+ try
+ {
+ var response = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.ListByServer(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken);
+ return Page.FromValues(response.Value.Value.Select(value => new ServerAdvancedThreatProtectionResource(Client, value)), response.Value.NextLink, response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ Page NextPageFunc(string nextLink, int? pageSizeHint)
+ {
+ using var scope = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("ServerAdvancedThreatProtectionCollection.GetAll");
+ scope.Start();
+ try
+ {
+ var response = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.ListByServerNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken);
+ return Page.FromValues(response.Value.Value.Select(value => new ServerAdvancedThreatProtectionResource(Client, value)), response.Value.NextLink, response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
+ }
+
+ ///
+ /// Checks to see if the resource exists in azure.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: ServerAdvancedThreatProtectionSettings_Get
+ ///
+ /// The name of the Advanced Threat Protection state.
+ /// The cancellation token to use.
+ public virtual async Task> ExistsAsync(AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ using var scope = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("ServerAdvancedThreatProtectionCollection.Exists");
+ scope.Start();
+ try
+ {
+ var response = await _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, advancedThreatProtectionName, 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.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: ServerAdvancedThreatProtectionSettings_Get
+ ///
+ /// The name of the Advanced Threat Protection state.
+ /// The cancellation token to use.
+ public virtual Response Exists(AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ using var scope = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("ServerAdvancedThreatProtectionCollection.Exists");
+ scope.Start();
+ try
+ {
+ var response = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, advancedThreatProtectionName, cancellationToken: cancellationToken);
+ return Response.FromValue(response.Value != null, 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/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionData.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionData.cs
new file mode 100644
index 000000000000..ed9825ceded0
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionData.cs
@@ -0,0 +1,41 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure.Core;
+using Azure.ResourceManager.Models;
+using Azure.ResourceManager.Sql.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ /// A class representing the ServerAdvancedThreatProtection data model.
+ public partial class ServerAdvancedThreatProtectionData : ResourceData
+ {
+ /// Initializes a new instance of ServerAdvancedThreatProtectionData.
+ public ServerAdvancedThreatProtectionData()
+ {
+ }
+
+ /// Initializes a new instance of ServerAdvancedThreatProtectionData.
+ /// The id.
+ /// The name.
+ /// The resourceType.
+ /// The systemData.
+ /// Specifies the state of the Advanced Threat Protection, whether it is enabled or disabled or a state has not been applied yet on the specific database or server.
+ /// Specifies the UTC creation time of the policy.
+ internal ServerAdvancedThreatProtectionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, AdvancedThreatProtectionState? state, DateTimeOffset? creationOn) : base(id, name, resourceType, systemData)
+ {
+ State = state;
+ CreationOn = creationOn;
+ }
+
+ /// Specifies the state of the Advanced Threat Protection, whether it is enabled or disabled or a state has not been applied yet on the specific database or server.
+ public AdvancedThreatProtectionState? State { get; set; }
+ /// Specifies the UTC creation time of the policy.
+ public DateTimeOffset? CreationOn { get; }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionResource.cs
new file mode 100644
index 000000000000..351bd9e4dadc
--- /dev/null
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionResource.cs
@@ -0,0 +1,198 @@
+// 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;
+using Azure.Core;
+using Azure.Core.Pipeline;
+using Azure.ResourceManager;
+using Azure.ResourceManager.Sql.Models;
+
+namespace Azure.ResourceManager.Sql
+{
+ ///
+ /// A Class representing a ServerAdvancedThreatProtection 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 GetServerAdvancedThreatProtectionResource method.
+ /// Otherwise you can get one from its parent resource using the GetServerAdvancedThreatProtection method.
+ ///
+ public partial class ServerAdvancedThreatProtectionResource : ArmResource
+ {
+ /// Generate the resource identifier of a instance.
+ public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string serverName, string advancedThreatProtectionName)
+ {
+ var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}";
+ return new ResourceIdentifier(resourceId);
+ }
+
+ private readonly ClientDiagnostics _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics;
+ private readonly ServerAdvancedThreatProtectionSettingsRestOperations _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient;
+ private readonly ServerAdvancedThreatProtectionData _data;
+
+ /// Initializes a new instance of the class for mocking.
+ protected ServerAdvancedThreatProtectionResource()
+ {
+ }
+
+ /// Initializes a new instance of the class.
+ /// The client parameters to use in these operations.
+ /// The resource that is the target of operations.
+ internal ServerAdvancedThreatProtectionResource(ArmClient client, ServerAdvancedThreatProtectionData 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 ServerAdvancedThreatProtectionResource(ArmClient client, ResourceIdentifier id) : base(client, id)
+ {
+ _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Sql", ResourceType.Namespace, Diagnostics);
+ TryGetApiVersion(ResourceType, out string serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsApiVersion);
+ _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient = new ServerAdvancedThreatProtectionSettingsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsApiVersion);
+#if DEBUG
+ ValidateResourceId(Id);
+#endif
+ }
+
+ /// Gets the resource type for the operations.
+ public static readonly ResourceType ResourceType = "Microsoft.Sql/servers/advancedThreatProtectionSettings";
+
+ /// 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 ServerAdvancedThreatProtectionData 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 server's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: ServerAdvancedThreatProtectionSettings_Get
+ ///
+ /// The cancellation token to use.
+ public virtual async Task> GetAsync(CancellationToken cancellationToken = default)
+ {
+ using var scope = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("ServerAdvancedThreatProtectionResource.Get");
+ scope.Start();
+ try
+ {
+ var response = await _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.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 ServerAdvancedThreatProtectionResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Get a server's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: ServerAdvancedThreatProtectionSettings_Get
+ ///
+ /// The cancellation token to use.
+ public virtual Response Get(CancellationToken cancellationToken = default)
+ {
+ using var scope = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("ServerAdvancedThreatProtectionResource.Get");
+ scope.Start();
+ try
+ {
+ var response = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken);
+ if (response.Value == null)
+ throw new RequestFailedException(response.GetRawResponse());
+ return Response.FromValue(new ServerAdvancedThreatProtectionResource(Client, response.Value), response.GetRawResponse());
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Creates or updates an Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: ServerAdvancedThreatProtectionSettings_CreateOrUpdate
+ ///
+ /// 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 server Advanced Threat Protection state.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual async Task> UpdateAsync(WaitUntil waitUntil, ServerAdvancedThreatProtectionData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(data, nameof(data));
+
+ using var scope = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("ServerAdvancedThreatProtectionResource.Update");
+ scope.Start();
+ try
+ {
+ var response = await _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false);
+ var operation = new SqlArmOperation(new ServerAdvancedThreatProtectionOperationSource(Client), _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics, Pipeline, _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location);
+ if (waitUntil == WaitUntil.Completed)
+ await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// Creates or updates an Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: ServerAdvancedThreatProtectionSettings_CreateOrUpdate
+ ///
+ /// 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 server Advanced Threat Protection state.
+ /// The cancellation token to use.
+ /// is null.
+ public virtual ArmOperation Update(WaitUntil waitUntil, ServerAdvancedThreatProtectionData data, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(data, nameof(data));
+
+ using var scope = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics.CreateScope("ServerAdvancedThreatProtectionResource.Update");
+ scope.Start();
+ try
+ {
+ var response = _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken);
+ var operation = new SqlArmOperation(new ServerAdvancedThreatProtectionOperationSource(Client), _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsClientDiagnostics, Pipeline, _serverAdvancedThreatProtectionServerAdvancedThreatProtectionSettingsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location);
+ if (waitUntil == WaitUntil.Completed)
+ operation.WaitForCompletion(cancellationToken);
+ return operation;
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+ }
+}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseResource.cs
index 489711ec9a62..55d9025ad358 100644
--- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseResource.cs
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseResource.cs
@@ -704,6 +704,39 @@ public virtual Response GetExtendedD
return GetExtendedDatabaseBlobAuditingPolicies().Get(blobAuditingPolicyName, cancellationToken);
}
+ /// Gets a collection of DatabaseAdvancedThreatProtectionResources in the SqlDatabase.
+ /// An object representing collection of DatabaseAdvancedThreatProtectionResources and their operations over a DatabaseAdvancedThreatProtectionResource.
+ public virtual DatabaseAdvancedThreatProtectionCollection GetDatabaseAdvancedThreatProtections()
+ {
+ return GetCachedClient(Client => new DatabaseAdvancedThreatProtectionCollection(Client, Id));
+ }
+
+ ///
+ /// Gets a database's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: DatabaseAdvancedThreatProtectionSettings_Get
+ ///
+ /// The name of the Advanced Threat Protection state.
+ /// The cancellation token to use.
+ [ForwardsClientCalls]
+ public virtual async Task> GetDatabaseAdvancedThreatProtectionAsync(AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ return await GetDatabaseAdvancedThreatProtections().GetAsync(advancedThreatProtectionName, cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// Gets a database's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: DatabaseAdvancedThreatProtectionSettings_Get
+ ///
+ /// The name of the Advanced Threat Protection state.
+ /// The cancellation token to use.
+ [ForwardsClientCalls]
+ public virtual Response GetDatabaseAdvancedThreatProtection(AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ return GetDatabaseAdvancedThreatProtections().Get(advancedThreatProtectionName, cancellationToken);
+ }
+
///
/// Gets a database.
/// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerResource.cs
index 1e77201d8f9f..40228dc7ab40 100644
--- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerResource.cs
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlServerResource.cs
@@ -1091,6 +1091,39 @@ public virtual Response GetExtendedSer
return GetExtendedServerBlobAuditingPolicies().Get(blobAuditingPolicyName, cancellationToken);
}
+ /// Gets a collection of ServerAdvancedThreatProtectionResources in the SqlServer.
+ /// An object representing collection of ServerAdvancedThreatProtectionResources and their operations over a ServerAdvancedThreatProtectionResource.
+ public virtual ServerAdvancedThreatProtectionCollection GetServerAdvancedThreatProtections()
+ {
+ return GetCachedClient(Client => new ServerAdvancedThreatProtectionCollection(Client, Id));
+ }
+
+ ///
+ /// Get a server's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: ServerAdvancedThreatProtectionSettings_Get
+ ///
+ /// The name of the Advanced Threat Protection state.
+ /// The cancellation token to use.
+ [ForwardsClientCalls]
+ public virtual async Task> GetServerAdvancedThreatProtectionAsync(AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ return await GetServerAdvancedThreatProtections().GetAsync(advancedThreatProtectionName, cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// Get a server's Advanced Threat Protection state.
+ /// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/advancedThreatProtectionSettings/{advancedThreatProtectionName}
+ /// Operation Id: ServerAdvancedThreatProtectionSettings_Get
+ ///
+ /// The name of the Advanced Threat Protection state.
+ /// The cancellation token to use.
+ [ForwardsClientCalls]
+ public virtual Response GetServerAdvancedThreatProtection(AdvancedThreatProtectionName advancedThreatProtectionName, CancellationToken cancellationToken = default)
+ {
+ return GetServerAdvancedThreatProtections().Get(advancedThreatProtectionName, cancellationToken);
+ }
+
///
/// Gets a server.
/// Request Path: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}
diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/autorest.md b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/autorest.md
index 7945d3643796..d6dfbe333109 100644
--- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/autorest.md
+++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/autorest.md
@@ -4,7 +4,7 @@ Run `dotnet build /t:GenerateCode` to generate code.
``` yaml
azure-arm: true
-require: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/55090ea4342b5dac48bc2e9706e3a59465ffa34c/specification/sql/resource-manager/readme.md
+require: https://github.com/Azure/azure-rest-api-specs/blob/91e3f1a863ca9ed650db1bfb2ec4f2ab8afd78f9/specification/sql/resource-manager/readme.md
namespace: Azure.ResourceManager.Sql
output-folder: $(this-folder)/Generated
model-namespace: false