From d8aafca7b71955dc6d2733ce159ccb95bf8e79d0 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 6 Jun 2022 12:02:55 +0000 Subject: [PATCH] CodeGen from PR 19333 in Azure/azure-rest-api-specs Merge ccef1b831e31b7c3ced80c0608a47d84094d5e25 into bacf902c3c6712103669a01f7d1b32c2ca084032 --- ...abaseAdvancedThreatProtectionCollection.cs | 314 ++++++++++++++ .../DatabaseAdvancedThreatProtectionData.cs | 41 ++ ...atabaseAdvancedThreatProtectionResource.cs | 198 +++++++++ .../src/Generated/Extensions/SqlExtensions.cs | 38 ++ ...AdvancedThreatProtectionOperationSource.cs | 40 ++ .../Models/AdvancedThreatProtectionName.cs | 48 +++ ...ncedThreatProtectionState.Serialization.cs | 30 ++ .../Models/AdvancedThreatProtectionState.cs | 20 + ...ancedThreatProtectionData.Serialization.cs | 98 +++++ ...hreatProtectionListResult.Serialization.cs | 47 +++ ...abaseAdvancedThreatProtectionListResult.cs | 37 ++ ...hreatProtectionListResult.Serialization.cs | 47 +++ ...erverAdvancedThreatProtectionListResult.cs | 37 ++ ...ancedThreatProtectionData.Serialization.cs | 98 +++++ ...dThreatProtectionSettingsRestOperations.cs | 395 ++++++++++++++++++ ...dThreatProtectionSettingsRestOperations.cs | 363 ++++++++++++++++ ...erverAdvancedThreatProtectionCollection.cs | 314 ++++++++++++++ .../ServerAdvancedThreatProtectionData.cs | 41 ++ .../ServerAdvancedThreatProtectionResource.cs | 198 +++++++++ .../src/Generated/SqlDatabaseResource.cs | 33 ++ .../src/Generated/SqlServerResource.cs | 33 ++ .../Azure.ResourceManager.Sql/src/autorest.md | 2 +- 22 files changed, 2471 insertions(+), 1 deletion(-) create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionCollection.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionData.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DatabaseAdvancedThreatProtectionResource.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/ServerAdvancedThreatProtectionOperationSource.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdvancedThreatProtectionName.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdvancedThreatProtectionState.Serialization.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/AdvancedThreatProtectionState.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionData.Serialization.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionListResult.Serialization.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseAdvancedThreatProtectionListResult.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerAdvancedThreatProtectionListResult.Serialization.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/LogicalServerAdvancedThreatProtectionListResult.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerAdvancedThreatProtectionData.Serialization.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/DatabaseAdvancedThreatProtectionSettingsRestOperations.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/ServerAdvancedThreatProtectionSettingsRestOperations.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionCollection.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionData.cs create mode 100644 sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerAdvancedThreatProtectionResource.cs 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..e2105377ca10 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,43 @@ 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 } } 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/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/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/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..d767193278a3 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/b641f945c2b843e1bff7d5b850e00ddf67ca6922/specification/sql/resource-manager/readme.md namespace: Azure.ResourceManager.Sql output-folder: $(this-folder)/Generated model-namespace: false