Skip to content

Commit

Permalink
Add Sql SDK code (#19602)
Browse files Browse the repository at this point in the history
  • Loading branch information
dingmeng-xue authored Sep 23, 2022
1 parent 4bf5408 commit 0ac6c87
Show file tree
Hide file tree
Showing 525 changed files with 167,901 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.

namespace Microsoft.Azure.Management.Sql
{
using Models;
using System.Threading;
using System.Threading.Tasks;

/// <summary>
/// Extension methods for DatabaseVulnerabilityAssessmentRuleBaselinesOperations.
/// </summary>
public static partial class DatabaseVulnerabilityAssessmentRuleBaselinesOperationsExtensions
{
/// <summary>
/// Gets a database's vulnerability assessment rule baseline.
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='resourceGroupName'>
/// The name of the resource group that contains the resource. You can obtain
/// this value from the Azure Resource Manager API or the portal.
/// </param>
/// <param name='serverName'>
/// The name of the server.
/// </param>
/// <param name='databaseName'>
/// The name of the database for which the vulnerability assessment rule
/// baseline is defined.
/// </param>
/// <param name='ruleId'>
/// The vulnerability assessment rule ID.
/// </param>
public static DatabaseVulnerabilityAssessmentRuleBaseline Get(this IDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations, string resourceGroupName, string serverName, string databaseName, string ruleId)
{
return Get(operations, resourceGroupName, serverName, databaseName, ruleId, VulnerabilityAssessmentPolicyBaselineName.Default);
}

/// <summary>
/// Gets a database's vulnerability assessment rule baseline.
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='resourceGroupName'>
/// The name of the resource group that contains the resource. You can obtain
/// this value from the Azure Resource Manager API or the portal.
/// </param>
/// <param name='serverName'>
/// The name of the server.
/// </param>
/// <param name='databaseName'>
/// The name of the database for which the vulnerability assessment rule
/// baseline is defined.
/// </param>
/// <param name='ruleId'>
/// The vulnerability assessment rule ID.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<DatabaseVulnerabilityAssessmentRuleBaseline> GetAsync(this IDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations, string resourceGroupName, string serverName, string databaseName, string ruleId, CancellationToken cancellationToken = default(CancellationToken))
{
return await GetAsync(operations, resourceGroupName, serverName, databaseName, ruleId, VulnerabilityAssessmentPolicyBaselineName.Default, cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Creates or updates a database's vulnerability assessment rule baseline.
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='resourceGroupName'>
/// The name of the resource group that contains the resource. You can obtain
/// this value from the Azure Resource Manager API or the portal.
/// </param>
/// <param name='serverName'>
/// The name of the server.
/// </param>
/// <param name='databaseName'>
/// The name of the database for which the vulnerability assessment rule
/// baseline is defined.
/// </param>
/// <param name='ruleId'>
/// The vulnerability assessment rule ID.
/// </param>
/// <param name='parameters'>
/// The requested rule baseline resource.
/// </param>
public static DatabaseVulnerabilityAssessmentRuleBaseline CreateOrUpdate(this IDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations, string resourceGroupName, string serverName, string databaseName, string ruleId, DatabaseVulnerabilityAssessmentRuleBaseline parameters)
{
return CreateOrUpdate(operations, resourceGroupName, serverName, databaseName, ruleId, VulnerabilityAssessmentPolicyBaselineName.Default, parameters);
}

/// <summary>
/// Creates or updates a database's vulnerability assessment rule baseline.
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='resourceGroupName'>
/// The name of the resource group that contains the resource. You can obtain
/// this value from the Azure Resource Manager API or the portal.
/// </param>
/// <param name='serverName'>
/// The name of the server.
/// </param>
/// <param name='databaseName'>
/// The name of the database for which the vulnerability assessment rule
/// baseline is defined.
/// </param>
/// <param name='ruleId'>
/// The vulnerability assessment rule ID.
/// </param>
/// <param name='parameters'>
/// The requested rule baseline resource.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<DatabaseVulnerabilityAssessmentRuleBaseline> CreateOrUpdateAsync(this IDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations, string resourceGroupName, string serverName, string databaseName, string ruleId, DatabaseVulnerabilityAssessmentRuleBaseline parameters, CancellationToken cancellationToken = default(CancellationToken))
{
return await CreateOrUpdateAsync(operations, resourceGroupName, serverName, databaseName, ruleId, VulnerabilityAssessmentPolicyBaselineName.Default, parameters, cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Removes the database's vulnerability assessment rule baseline.
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='resourceGroupName'>
/// The name of the resource group that contains the resource. You can obtain
/// this value from the Azure Resource Manager API or the portal.
/// </param>
/// <param name='serverName'>
/// The name of the server.
/// </param>
/// <param name='databaseName'>
/// The name of the database for which the vulnerability assessment rule
/// baseline is defined.
/// </param>
/// <param name='ruleId'>
/// The vulnerability assessment rule ID.
/// </param>
public static void Delete(this IDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations, string resourceGroupName, string serverName, string databaseName, string ruleId)
{
Delete(operations, resourceGroupName, serverName, databaseName, ruleId, VulnerabilityAssessmentPolicyBaselineName.Default);
}

/// <summary>
/// Removes the database's vulnerability assessment rule baseline.
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='resourceGroupName'>
/// The name of the resource group that contains the resource. You can obtain
/// this value from the Azure Resource Manager API or the portal.
/// </param>
/// <param name='serverName'>
/// The name of the server.
/// </param>
/// <param name='databaseName'>
/// The name of the database for which the vulnerability assessment rule
/// baseline is defined.
/// </param>
/// <param name='ruleId'>
/// The vulnerability assessment rule ID.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task DeleteAsync(this IDatabaseVulnerabilityAssessmentRuleBaselinesOperations operations, string resourceGroupName, string serverName, string databaseName, string ruleId, CancellationToken cancellationToken = default(CancellationToken))
{
await DeleteAsync(operations, resourceGroupName, serverName, databaseName, ruleId, VulnerabilityAssessmentPolicyBaselineName.Default, cancellationToken).ConfigureAwait(false);
}
}
}
112 changes: 112 additions & 0 deletions src/Sql/Sql.Sdk/Customizations/DatabasesOperations.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.

namespace Microsoft.Azure.Management.Sql
{
using Microsoft.Rest;
using Microsoft.Rest.Azure;
using Models;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

internal partial class DatabasesOperations
{
/// <summary>
/// Renames a database.
/// </summary>
/// <param name='resourceGroupName'>
/// The name of the resource group that contains the resource. You can
/// obtain this value from the Azure Resource Manager API or the
/// portal.
/// </param>
/// <param name='serverName'>
/// The name of the server.
/// </param>
/// <param name='databaseName'>
/// The name of the database to rename.
/// </param>
/// <param name='newName'>
/// The new name that the database should be renamed to.
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.Azure.CloudException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
public async Task<AzureOperationResponse> RenameWithHttpMessagesAsync(
string resourceGroupName,
string serverName,
string databaseName,
string newName,
Dictionary<string, List<string>> customHeaders = null,
CancellationToken cancellationToken = default(CancellationToken))
{
return await this.RenameWithHttpMessagesAsync(
resourceGroupName,
serverName,
databaseName,
new Models.ResourceMoveDefinition(
string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Sql/servers/{2}/databases/{3}",
this.Client.SubscriptionId,
resourceGroupName,
serverName,
newName)),
customHeaders,
cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Gets a list of databases.
/// </summary>
/// <param name='resourceGroupName'>
/// The name of the resource group that contains the resource. You can obtain
/// this value from the Azure Resource Manager API or the portal.
/// </param>
/// <param name='serverName'>
/// The name of the server.
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="CloudException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="ValidationException">
/// Thrown when a required parameter is null
/// </exception>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse<IPage<Database>>> ListByServerWithHttpMessagesAsync(
string resourceGroupName,
string serverName,
Dictionary<string, List<string>> customHeaders,
CancellationToken cancellationToken = default(CancellationToken))
{
return await this.ListByServerWithHttpMessagesAsync(
resourceGroupName,
serverName,
null,
customHeaders,
cancellationToken).ConfigureAwait(false);
}
}
}
Loading

0 comments on commit 0ac6c87

Please sign in to comment.