diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DistributedAvailabilityGroup.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DistributedAvailabilityGroup.cs new file mode 100644 index 000000000000..0885371bba5f --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DistributedAvailabilityGroup.cs @@ -0,0 +1,281 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Core; +using Azure.ResourceManager.Sql.Models; + +namespace Azure.ResourceManager.Sql +{ + /// A Class representing a DistributedAvailabilityGroup along with the instance operations that can be performed on it. + public partial class DistributedAvailabilityGroup : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string managedInstanceName, string distributedAvailabilityGroupName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName}"; + return new ResourceIdentifier(resourceId); + } + private readonly ClientDiagnostics _clientDiagnostics; + private readonly DistributedAvailabilityGroupsRestOperations _distributedAvailabilityGroupsRestClient; + private readonly DistributedAvailabilityGroupData _data; + + /// Initializes a new instance of the class for mocking. + protected DistributedAvailabilityGroup() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal DistributedAvailabilityGroup(ArmResource options, DistributedAvailabilityGroupData resource) : base(options, resource.Id) + { + HasData = true; + _data = resource; + _clientDiagnostics = new ClientDiagnostics(ClientOptions); + _distributedAvailabilityGroupsRestClient = new DistributedAvailabilityGroupsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 DistributedAvailabilityGroup(ArmResource options, ResourceIdentifier id) : base(options, id) + { + _clientDiagnostics = new ClientDiagnostics(ClientOptions); + _distributedAvailabilityGroupsRestClient = new DistributedAvailabilityGroupsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Initializes a new instance of the class. + /// The client options to build client context. + /// The credential to build client context. + /// The uri to build client context. + /// The pipeline to build client context. + /// The identifier of the resource that is the target of operations. + internal DistributedAvailabilityGroup(ArmClientOptions clientOptions, TokenCredential credential, Uri uri, HttpPipeline pipeline, ResourceIdentifier id) : base(clientOptions, credential, uri, pipeline, id) + { + _clientDiagnostics = new ClientDiagnostics(ClientOptions); + _distributedAvailabilityGroupsRestClient = new DistributedAvailabilityGroupsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Sql/managedInstances/distributedAvailabilityGroups"; + + /// 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 DistributedAvailabilityGroupData 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)); + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// OperationId: DistributedAvailabilityGroups_Get + /// Gets a distributed availability group info. + /// The cancellation token to use. + public async virtual Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroup.Get"); + scope.Start(); + try + { + var response = await _distributedAvailabilityGroupsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); + return Response.FromValue(new DistributedAvailabilityGroup(this, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// OperationId: DistributedAvailabilityGroups_Get + /// Gets a distributed availability group info. + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroup.Get"); + scope.Start(); + try + { + var response = _distributedAvailabilityGroupsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DistributedAvailabilityGroup(this, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Lists all available geo-locations. + /// A token to allow the caller to cancel the call to the service. The default value is . + /// A collection of locations that may take multiple service requests to iterate over. + public async virtual Task> GetAvailableLocationsAsync(CancellationToken cancellationToken = default) + { + return await ListAvailableLocationsAsync(ResourceType, cancellationToken).ConfigureAwait(false); + } + + /// Lists all available geo-locations. + /// A token to allow the caller to cancel the call to the service. The default value is . + /// A collection of locations that may take multiple service requests to iterate over. + public virtual IEnumerable GetAvailableLocations(CancellationToken cancellationToken = default) + { + return ListAvailableLocations(ResourceType, cancellationToken); + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// OperationId: DistributedAvailabilityGroups_Delete + /// Drops a distributed availability group between Sql On-Prem and Sql Managed Instance. + /// Waits for the completion of the long running operations. + /// The cancellation token to use. + public async virtual Task DeleteAsync(bool waitForCompletion = true, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroup.Delete"); + scope.Start(); + try + { + var response = await _distributedAvailabilityGroupsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new DistributedAvailabilityGroupDeleteOperation(_clientDiagnostics, Pipeline, _distributedAvailabilityGroupsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response); + if (waitForCompletion) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// OperationId: DistributedAvailabilityGroups_Delete + /// Drops a distributed availability group between Sql On-Prem and Sql Managed Instance. + /// Waits for the completion of the long running operations. + /// The cancellation token to use. + public virtual DistributedAvailabilityGroupDeleteOperation Delete(bool waitForCompletion = true, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroup.Delete"); + scope.Start(); + try + { + var response = _distributedAvailabilityGroupsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new DistributedAvailabilityGroupDeleteOperation(_clientDiagnostics, Pipeline, _distributedAvailabilityGroupsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response); + if (waitForCompletion) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// OperationId: DistributedAvailabilityGroups_Update + /// Updates a distributed availability group replication mode. + /// The distributed availability group info. + /// Waits for the completion of the long running operations. + /// The cancellation token to use. + /// is null. + public async virtual Task UpdateAsync(DistributedAvailabilityGroupData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) + { + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroup.Update"); + scope.Start(); + try + { + var response = await _distributedAvailabilityGroupsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, parameters, cancellationToken).ConfigureAwait(false); + var operation = new DistributedAvailabilityGroupUpdateOperation(this, _clientDiagnostics, Pipeline, _distributedAvailabilityGroupsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, parameters).Request, response); + if (waitForCompletion) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// OperationId: DistributedAvailabilityGroups_Update + /// Updates a distributed availability group replication mode. + /// The distributed availability group info. + /// Waits for the completion of the long running operations. + /// The cancellation token to use. + /// is null. + public virtual DistributedAvailabilityGroupUpdateOperation Update(DistributedAvailabilityGroupData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) + { + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroup.Update"); + scope.Start(); + try + { + var response = _distributedAvailabilityGroupsRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, parameters, cancellationToken); + var operation = new DistributedAvailabilityGroupUpdateOperation(this, _clientDiagnostics, Pipeline, _distributedAvailabilityGroupsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, parameters).Request, response); + if (waitForCompletion) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DistributedAvailabilityGroupCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DistributedAvailabilityGroupCollection.cs new file mode 100644 index 000000000000..57dff89fca16 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DistributedAvailabilityGroupCollection.cs @@ -0,0 +1,391 @@ +// 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.Core; +using Azure.ResourceManager.Sql.Models; + +namespace Azure.ResourceManager.Sql +{ + /// A class representing collection of DistributedAvailabilityGroup and their operations over its parent. + public partial class DistributedAvailabilityGroupCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly DistributedAvailabilityGroupsRestOperations _distributedAvailabilityGroupsRestClient; + + /// Initializes a new instance of the class for mocking. + protected DistributedAvailabilityGroupCollection() + { + } + + /// Initializes a new instance of DistributedAvailabilityGroupCollection class. + /// The resource representing the parent resource. + internal DistributedAvailabilityGroupCollection(ArmResource parent) : base(parent) + { + _clientDiagnostics = new ClientDiagnostics(ClientOptions); + _distributedAvailabilityGroupsRestClient = new DistributedAvailabilityGroupsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ManagedInstance.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ManagedInstance.ResourceType), nameof(id)); + } + + // Collection level operations. + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: DistributedAvailabilityGroups_CreateOrUpdate + /// Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. + /// The distributed availability group name. + /// The distributed availability group info. + /// Waits for the completion of the long running operations. + /// The cancellation token to use. + /// or is null. + public virtual DistributedAvailabilityGroupCreateOrUpdateOperation CreateOrUpdate(string distributedAvailabilityGroupName, DistributedAvailabilityGroupData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) + { + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroupCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _distributedAvailabilityGroupsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, distributedAvailabilityGroupName, parameters, cancellationToken); + var operation = new DistributedAvailabilityGroupCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _distributedAvailabilityGroupsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, distributedAvailabilityGroupName, parameters).Request, response); + if (waitForCompletion) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: DistributedAvailabilityGroups_CreateOrUpdate + /// Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. + /// The distributed availability group name. + /// The distributed availability group info. + /// Waits for the completion of the long running operations. + /// The cancellation token to use. + /// or is null. + public async virtual Task CreateOrUpdateAsync(string distributedAvailabilityGroupName, DistributedAvailabilityGroupData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) + { + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroupCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _distributedAvailabilityGroupsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, distributedAvailabilityGroupName, parameters, cancellationToken).ConfigureAwait(false); + var operation = new DistributedAvailabilityGroupCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _distributedAvailabilityGroupsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, distributedAvailabilityGroupName, parameters).Request, response); + if (waitForCompletion) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: DistributedAvailabilityGroups_Get + /// Gets a distributed availability group info. + /// The distributed availability group name. + /// The cancellation token to use. + /// is null. + public virtual Response Get(string distributedAvailabilityGroupName, CancellationToken cancellationToken = default) + { + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroupCollection.Get"); + scope.Start(); + try + { + var response = _distributedAvailabilityGroupsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, distributedAvailabilityGroupName, cancellationToken); + if (response.Value == null) + throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); + return Response.FromValue(new DistributedAvailabilityGroup(Parent, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups/{distributedAvailabilityGroupName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: DistributedAvailabilityGroups_Get + /// Gets a distributed availability group info. + /// The distributed availability group name. + /// The cancellation token to use. + /// is null. + public async virtual Task> GetAsync(string distributedAvailabilityGroupName, CancellationToken cancellationToken = default) + { + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroupCollection.Get"); + scope.Start(); + try + { + var response = await _distributedAvailabilityGroupsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, distributedAvailabilityGroupName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); + return Response.FromValue(new DistributedAvailabilityGroup(Parent, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Tries to get details for this resource from the service. + /// The distributed availability group name. + /// The cancellation token to use. + /// is null. + public virtual Response GetIfExists(string distributedAvailabilityGroupName, CancellationToken cancellationToken = default) + { + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroupCollection.GetIfExists"); + scope.Start(); + try + { + var response = _distributedAvailabilityGroupsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, distributedAvailabilityGroupName, cancellationToken: cancellationToken); + return response.Value == null + ? Response.FromValue(null, response.GetRawResponse()) + : Response.FromValue(new DistributedAvailabilityGroup(this, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Tries to get details for this resource from the service. + /// The distributed availability group name. + /// The cancellation token to use. + /// is null. + public async virtual Task> GetIfExistsAsync(string distributedAvailabilityGroupName, CancellationToken cancellationToken = default) + { + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroupCollection.GetIfExistsAsync"); + scope.Start(); + try + { + var response = await _distributedAvailabilityGroupsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, distributedAvailabilityGroupName, cancellationToken: cancellationToken).ConfigureAwait(false); + return response.Value == null + ? Response.FromValue(null, response.GetRawResponse()) + : Response.FromValue(new DistributedAvailabilityGroup(this, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Tries to get details for this resource from the service. + /// The distributed availability group name. + /// The cancellation token to use. + /// is null. + public virtual Response Exists(string distributedAvailabilityGroupName, CancellationToken cancellationToken = default) + { + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroupCollection.Exists"); + scope.Start(); + try + { + var response = GetIfExists(distributedAvailabilityGroupName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Tries to get details for this resource from the service. + /// The distributed availability group name. + /// The cancellation token to use. + /// is null. + public async virtual Task> ExistsAsync(string distributedAvailabilityGroupName, CancellationToken cancellationToken = default) + { + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroupCollection.ExistsAsync"); + scope.Start(); + try + { + var response = await GetIfExistsAsync(distributedAvailabilityGroupName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: DistributedAvailabilityGroups_ListByInstance + /// Gets a list of a distributed availability groups in instance. + /// 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 = _clientDiagnostics.CreateScope("DistributedAvailabilityGroupCollection.GetAll"); + scope.Start(); + try + { + var response = _distributedAvailabilityGroupsRestClient.ListByInstance(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value.Select(value => new DistributedAvailabilityGroup(Parent, value)), response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroupCollection.GetAll"); + scope.Start(); + try + { + var response = _distributedAvailabilityGroupsRestClient.ListByInstanceNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value.Select(value => new DistributedAvailabilityGroup(Parent, value)), response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/distributedAvailabilityGroups + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: DistributedAvailabilityGroups_ListByInstance + /// Gets a list of a distributed availability groups in instance. + /// 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 = _clientDiagnostics.CreateScope("DistributedAvailabilityGroupCollection.GetAll"); + scope.Start(); + try + { + var response = await _distributedAvailabilityGroupsRestClient.ListByInstanceAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value.Select(value => new DistributedAvailabilityGroup(Parent, value)), response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("DistributedAvailabilityGroupCollection.GetAll"); + scope.Start(); + try + { + var response = await _distributedAvailabilityGroupsRestClient.ListByInstanceNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value.Select(value => new DistributedAvailabilityGroup(Parent, value)), response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + + // Builders. + // public ArmBuilder Construct() { } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DistributedAvailabilityGroupData.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DistributedAvailabilityGroupData.cs new file mode 100644 index 000000000000..8ff8da253b5f --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/DistributedAvailabilityGroupData.cs @@ -0,0 +1,72 @@ +// 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 DistributedAvailabilityGroup data model. + public partial class DistributedAvailabilityGroupData : Resource + { + /// Initializes a new instance of DistributedAvailabilityGroupData. + public DistributedAvailabilityGroupData() + { + } + + /// Initializes a new instance of DistributedAvailabilityGroupData. + /// The id. + /// The name. + /// The type. + /// The name of the target database. + /// The source endpoint. + /// The primary availability group name. + /// The secondary availability group name. + /// The replication mode of a distributed availability group. Parameter will be ignored during link creation. + /// The distributed availability group id. + /// The source replica id. + /// The target replica id. + /// The link state. + /// The last hardened lsn. + internal DistributedAvailabilityGroupData(ResourceIdentifier id, string name, ResourceType type, string targetDatabase, string sourceEndpoint, string primaryAvailabilityGroupName, string secondaryAvailabilityGroupName, ReplicationMode? replicationMode, Guid? distributedAvailabilityGroupId, Guid? sourceReplicaId, Guid? targetReplicaId, string linkState, string lastHardenedLsn) : base(id, name, type) + { + TargetDatabase = targetDatabase; + SourceEndpoint = sourceEndpoint; + PrimaryAvailabilityGroupName = primaryAvailabilityGroupName; + SecondaryAvailabilityGroupName = secondaryAvailabilityGroupName; + ReplicationMode = replicationMode; + DistributedAvailabilityGroupId = distributedAvailabilityGroupId; + SourceReplicaId = sourceReplicaId; + TargetReplicaId = targetReplicaId; + LinkState = linkState; + LastHardenedLsn = lastHardenedLsn; + } + + /// The name of the target database. + public string TargetDatabase { get; set; } + /// The source endpoint. + public string SourceEndpoint { get; set; } + /// The primary availability group name. + public string PrimaryAvailabilityGroupName { get; set; } + /// The secondary availability group name. + public string SecondaryAvailabilityGroupName { get; set; } + /// The replication mode of a distributed availability group. Parameter will be ignored during link creation. + public ReplicationMode? ReplicationMode { get; set; } + /// The distributed availability group id. + public Guid? DistributedAvailabilityGroupId { get; } + /// The source replica id. + public Guid? SourceReplicaId { get; } + /// The target replica id. + public Guid? TargetReplicaId { get; } + /// The link state. + public string LinkState { get; } + /// The last hardened lsn. + public string LastHardenedLsn { get; } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/ArmClientExtensions.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/ArmClientExtensions.cs index aecc8352fd2c..141175cc5abd 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/ArmClientExtensions.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/ArmClientExtensions.cs @@ -565,54 +565,6 @@ public static JobVersion GetJobVersion(this ArmClient armClient, ResourceIdentif } #endregion - #region SubscriptionLongTermRetentionBackup - /// Gets an object representing a SubscriptionLongTermRetentionBackup along with the instance operations that can be performed on it but with no data. - /// The instance the method will execute against. - /// The resource ID of the resource to get. - /// Returns a object. - public static SubscriptionLongTermRetentionBackup GetSubscriptionLongTermRetentionBackup(this ArmClient armClient, ResourceIdentifier id) - { - SubscriptionLongTermRetentionBackup.ValidateResourceId(id); - return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new SubscriptionLongTermRetentionBackup(clientOptions, credential, uri, pipeline, id)); - } - #endregion - - #region ResourceGroupLongTermRetentionBackup - /// Gets an object representing a ResourceGroupLongTermRetentionBackup along with the instance operations that can be performed on it but with no data. - /// The instance the method will execute against. - /// The resource ID of the resource to get. - /// Returns a object. - public static ResourceGroupLongTermRetentionBackup GetResourceGroupLongTermRetentionBackup(this ArmClient armClient, ResourceIdentifier id) - { - ResourceGroupLongTermRetentionBackup.ValidateResourceId(id); - return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new ResourceGroupLongTermRetentionBackup(clientOptions, credential, uri, pipeline, id)); - } - #endregion - - #region SubscriptionLongTermRetentionManagedInstanceBackup - /// Gets an object representing a SubscriptionLongTermRetentionManagedInstanceBackup along with the instance operations that can be performed on it but with no data. - /// The instance the method will execute against. - /// The resource ID of the resource to get. - /// Returns a object. - public static SubscriptionLongTermRetentionManagedInstanceBackup GetSubscriptionLongTermRetentionManagedInstanceBackup(this ArmClient armClient, ResourceIdentifier id) - { - SubscriptionLongTermRetentionManagedInstanceBackup.ValidateResourceId(id); - return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new SubscriptionLongTermRetentionManagedInstanceBackup(clientOptions, credential, uri, pipeline, id)); - } - #endregion - - #region ResourceGroupLongTermRetentionManagedInstanceBackup - /// Gets an object representing a ResourceGroupLongTermRetentionManagedInstanceBackup along with the instance operations that can be performed on it but with no data. - /// The instance the method will execute against. - /// The resource ID of the resource to get. - /// Returns a object. - public static ResourceGroupLongTermRetentionManagedInstanceBackup GetResourceGroupLongTermRetentionManagedInstanceBackup(this ArmClient armClient, ResourceIdentifier id) - { - ResourceGroupLongTermRetentionManagedInstanceBackup.ValidateResourceId(id); - return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new ResourceGroupLongTermRetentionManagedInstanceBackup(clientOptions, credential, uri, pipeline, id)); - } - #endregion - #region LongTermRetentionPolicy /// Gets an object representing a LongTermRetentionPolicy along with the instance operations that can be performed on it but with no data. /// The instance the method will execute against. @@ -841,18 +793,6 @@ public static ManagedInstancePrivateLink GetManagedInstancePrivateLink(this ArmC } #endregion - #region ManagedInstance - /// Gets an object representing a ManagedInstance along with the instance operations that can be performed on it but with no data. - /// The instance the method will execute against. - /// The resource ID of the resource to get. - /// Returns a object. - public static ManagedInstance GetManagedInstance(this ArmClient armClient, ResourceIdentifier id) - { - ManagedInstance.ValidateResourceId(id); - return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new ManagedInstance(clientOptions, credential, uri, pipeline, id)); - } - #endregion - #region ManagedInstanceVulnerabilityAssessment /// Gets an object representing a ManagedInstanceVulnerabilityAssessment along with the instance operations that can be performed on it but with no data. /// The instance the method will execute against. @@ -1201,6 +1141,78 @@ public static OutboundFirewallRule GetOutboundFirewallRule(this ArmClient armCli } #endregion + #region SqlServer + /// Gets an object representing a SqlServer along with the instance operations that can be performed on it but with no data. + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static SqlServer GetSqlServer(this ArmClient armClient, ResourceIdentifier id) + { + SqlServer.ValidateResourceId(id); + return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new SqlServer(clientOptions, credential, uri, pipeline, id)); + } + #endregion + + #region SubscriptionLongTermRetentionBackup + /// Gets an object representing a SubscriptionLongTermRetentionBackup along with the instance operations that can be performed on it but with no data. + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static SubscriptionLongTermRetentionBackup GetSubscriptionLongTermRetentionBackup(this ArmClient armClient, ResourceIdentifier id) + { + SubscriptionLongTermRetentionBackup.ValidateResourceId(id); + return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new SubscriptionLongTermRetentionBackup(clientOptions, credential, uri, pipeline, id)); + } + #endregion + + #region ResourceGroupLongTermRetentionBackup + /// Gets an object representing a ResourceGroupLongTermRetentionBackup along with the instance operations that can be performed on it but with no data. + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static ResourceGroupLongTermRetentionBackup GetResourceGroupLongTermRetentionBackup(this ArmClient armClient, ResourceIdentifier id) + { + ResourceGroupLongTermRetentionBackup.ValidateResourceId(id); + return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new ResourceGroupLongTermRetentionBackup(clientOptions, credential, uri, pipeline, id)); + } + #endregion + + #region SubscriptionLongTermRetentionManagedInstanceBackup + /// Gets an object representing a SubscriptionLongTermRetentionManagedInstanceBackup along with the instance operations that can be performed on it but with no data. + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static SubscriptionLongTermRetentionManagedInstanceBackup GetSubscriptionLongTermRetentionManagedInstanceBackup(this ArmClient armClient, ResourceIdentifier id) + { + SubscriptionLongTermRetentionManagedInstanceBackup.ValidateResourceId(id); + return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new SubscriptionLongTermRetentionManagedInstanceBackup(clientOptions, credential, uri, pipeline, id)); + } + #endregion + + #region ResourceGroupLongTermRetentionManagedInstanceBackup + /// Gets an object representing a ResourceGroupLongTermRetentionManagedInstanceBackup along with the instance operations that can be performed on it but with no data. + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static ResourceGroupLongTermRetentionManagedInstanceBackup GetResourceGroupLongTermRetentionManagedInstanceBackup(this ArmClient armClient, ResourceIdentifier id) + { + ResourceGroupLongTermRetentionManagedInstanceBackup.ValidateResourceId(id); + return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new ResourceGroupLongTermRetentionManagedInstanceBackup(clientOptions, credential, uri, pipeline, id)); + } + #endregion + + #region ManagedInstance + /// Gets an object representing a ManagedInstance along with the instance operations that can be performed on it but with no data. + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static ManagedInstance GetManagedInstance(this ArmClient armClient, ResourceIdentifier id) + { + ManagedInstance.ValidateResourceId(id); + return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new ManagedInstance(clientOptions, credential, uri, pipeline, id)); + } + #endregion + #region RestorableDroppedDatabase /// Gets an object representing a RestorableDroppedDatabase along with the instance operations that can be performed on it but with no data. /// The instance the method will execute against. @@ -1225,18 +1237,6 @@ public static RestorableDroppedManagedDatabase GetRestorableDroppedManagedDataba } #endregion - #region SqlServer - /// Gets an object representing a SqlServer along with the instance operations that can be performed on it but with no data. - /// The instance the method will execute against. - /// The resource ID of the resource to get. - /// Returns a object. - public static SqlServer GetSqlServer(this ArmClient armClient, ResourceIdentifier id) - { - SqlServer.ValidateResourceId(id); - return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new SqlServer(clientOptions, credential, uri, pipeline, id)); - } - #endregion - #region ServerConnectionPolicy /// Gets an object representing a ServerConnectionPolicy along with the instance operations that can be performed on it but with no data. /// The instance the method will execute against. @@ -1248,5 +1248,29 @@ public static ServerConnectionPolicy GetServerConnectionPolicy(this ArmClient ar return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new ServerConnectionPolicy(clientOptions, credential, uri, pipeline, id)); } #endregion + + #region DistributedAvailabilityGroup + /// Gets an object representing a DistributedAvailabilityGroup along with the instance operations that can be performed on it but with no data. + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static DistributedAvailabilityGroup GetDistributedAvailabilityGroup(this ArmClient armClient, ResourceIdentifier id) + { + DistributedAvailabilityGroup.ValidateResourceId(id); + return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new DistributedAvailabilityGroup(clientOptions, credential, uri, pipeline, id)); + } + #endregion + + #region ServerTrustCertificate + /// Gets an object representing a ServerTrustCertificate along with the instance operations that can be performed on it but with no data. + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// Returns a object. + public static ServerTrustCertificate GetServerTrustCertificate(this ArmClient armClient, ResourceIdentifier id) + { + ServerTrustCertificate.ValidateResourceId(id); + return armClient.UseClientContext((uri, credential, clientOptions, pipeline) => new ServerTrustCertificate(clientOptions, credential, uri, pipeline, id)); + } + #endregion } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/ResourceGroupExtensions.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/ResourceGroupExtensions.cs index 4e3fff5d1dde..e1d045efd60e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/ResourceGroupExtensions.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/ResourceGroupExtensions.cs @@ -41,6 +41,37 @@ public static InstancePoolCollection GetInstancePools(this ResourceGroup resourc } #endregion + #region ServerTrustGroup + /// Gets an object representing a ServerTrustGroupCollection along with the instance operations that can be performed on it. + /// The instance the method will execute against. + /// The name of the region where the resource is located. + /// Returns a object. + public static ServerTrustGroupCollection GetServerTrustGroups(this ResourceGroup resourceGroup, string locationName) + { + return new ServerTrustGroupCollection(resourceGroup, locationName); + } + #endregion + + #region VirtualCluster + /// Gets an object representing a VirtualClusterCollection along with the instance operations that can be performed on it. + /// The instance the method will execute against. + /// Returns a object. + public static VirtualClusterCollection GetVirtualClusters(this ResourceGroup resourceGroup) + { + return new VirtualClusterCollection(resourceGroup); + } + #endregion + + #region SqlServer + /// Gets an object representing a SqlServerCollection along with the instance operations that can be performed on it. + /// The instance the method will execute against. + /// Returns a object. + public static SqlServerCollection GetSqlServers(this ResourceGroup resourceGroup) + { + return new SqlServerCollection(resourceGroup); + } + #endregion + #region ResourceGroupLongTermRetentionBackup /// Gets an object representing a ResourceGroupLongTermRetentionBackupCollection along with the instance operations that can be performed on it. /// The instance the method will execute against. @@ -77,37 +108,6 @@ public static ManagedInstanceCollection GetManagedInstances(this ResourceGroup r } #endregion - #region ServerTrustGroup - /// Gets an object representing a ServerTrustGroupCollection along with the instance operations that can be performed on it. - /// The instance the method will execute against. - /// The name of the region where the resource is located. - /// Returns a object. - public static ServerTrustGroupCollection GetServerTrustGroups(this ResourceGroup resourceGroup, string locationName) - { - return new ServerTrustGroupCollection(resourceGroup, locationName); - } - #endregion - - #region VirtualCluster - /// Gets an object representing a VirtualClusterCollection along with the instance operations that can be performed on it. - /// The instance the method will execute against. - /// Returns a object. - public static VirtualClusterCollection GetVirtualClusters(this ResourceGroup resourceGroup) - { - return new VirtualClusterCollection(resourceGroup); - } - #endregion - - #region SqlServer - /// Gets an object representing a SqlServerCollection along with the instance operations that can be performed on it. - /// The instance the method will execute against. - /// Returns a object. - public static SqlServerCollection GetSqlServers(this ResourceGroup resourceGroup) - { - return new SqlServerCollection(resourceGroup); - } - #endregion - private static LongTermRetentionBackupsRestOperations GetLongTermRetentionBackupsRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) { return new LongTermRetentionBackupsRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/SubscriptionExtensions.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/SubscriptionExtensions.cs index 6013e347d3c6..8f15b7745415 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/SubscriptionExtensions.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Extensions/SubscriptionExtensions.cs @@ -34,6 +34,28 @@ public static DeletedServerCollection GetDeletedServers(this Subscription subscr } #endregion + #region SubscriptionUsage + /// Gets an object representing a SubscriptionUsageCollection along with the instance operations that can be performed on it. + /// The instance the method will execute against. + /// The name of the region where the resource is located. + /// Returns a object. + public static SubscriptionUsageCollection GetSubscriptionUsages(this Subscription subscription, string locationName) + { + return new SubscriptionUsageCollection(subscription, locationName); + } + #endregion + + #region SqlTimeZone + /// Gets an object representing a SqlTimeZoneCollection along with the instance operations that can be performed on it. + /// The instance the method will execute against. + /// The String to use. + /// Returns a object. + public static SqlTimeZoneCollection GetSqlTimeZones(this Subscription subscription, string locationName) + { + return new SqlTimeZoneCollection(subscription, locationName); + } + #endregion + #region SubscriptionLongTermRetentionBackup /// Gets an object representing a SubscriptionLongTermRetentionBackupCollection along with the instance operations that can be performed on it. /// The instance the method will execute against. @@ -60,28 +82,6 @@ public static SubscriptionLongTermRetentionManagedInstanceBackupCollection GetSu } #endregion - #region SubscriptionUsage - /// Gets an object representing a SubscriptionUsageCollection along with the instance operations that can be performed on it. - /// The instance the method will execute against. - /// The name of the region where the resource is located. - /// Returns a object. - public static SubscriptionUsageCollection GetSubscriptionUsages(this Subscription subscription, string locationName) - { - return new SubscriptionUsageCollection(subscription, locationName); - } - #endregion - - #region SqlTimeZone - /// Gets an object representing a SqlTimeZoneCollection along with the instance operations that can be performed on it. - /// The instance the method will execute against. - /// The String to use. - /// Returns a object. - public static SqlTimeZoneCollection GetSqlTimeZones(this Subscription subscription, string locationName) - { - return new SqlTimeZoneCollection(subscription, locationName); - } - #endregion - private static DeletedServersRestOperations GetDeletedServersRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) { return new DeletedServersRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); @@ -97,39 +97,34 @@ private static CapabilitiesRestOperations GetCapabilitiesRestOperations(ClientDi return new CapabilitiesRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); } - private static LongTermRetentionBackupsRestOperations GetLongTermRetentionBackupsRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) - { - return new LongTermRetentionBackupsRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); - } - - private static LongTermRetentionManagedInstanceBackupsRestOperations GetLongTermRetentionManagedInstanceBackupsRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) + private static SyncGroupsRestOperations GetSyncGroupsRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) { - return new LongTermRetentionManagedInstanceBackupsRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); + return new SyncGroupsRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); } - private static ManagedInstancesRestOperations GetManagedInstancesRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) + private static VirtualClustersRestOperations GetVirtualClustersRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) { - return new ManagedInstancesRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); + return new VirtualClustersRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); } - private static OperationsHealthRestOperations GetOperationsHealthRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) + private static ServersRestOperations GetServersRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) { - return new OperationsHealthRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); + return new ServersRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); } - private static SyncGroupsRestOperations GetSyncGroupsRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) + private static LongTermRetentionBackupsRestOperations GetLongTermRetentionBackupsRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) { - return new SyncGroupsRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); + return new LongTermRetentionBackupsRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); } - private static VirtualClustersRestOperations GetVirtualClustersRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) + private static LongTermRetentionManagedInstanceBackupsRestOperations GetLongTermRetentionManagedInstanceBackupsRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) { - return new VirtualClustersRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); + return new LongTermRetentionManagedInstanceBackupsRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); } - private static ServersRestOperations GetServersRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) + private static ManagedInstancesRestOperations GetManagedInstancesRestOperations(ClientDiagnostics clientDiagnostics, TokenCredential credential, ArmClientOptions clientOptions, HttpPipeline pipeline, Uri endpoint = null) { - return new ServersRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); + return new ManagedInstancesRestOperations(clientDiagnostics, pipeline, clientOptions, endpoint); } /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/deletedServers @@ -452,18 +447,16 @@ public static Response GetByLocationCapability(this Subscr ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/syncDatabaseIds /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: LongTermRetentionBackups_ListByLocation - /// Lists the LongTermRetentionBackupData for this . + /// OperationId: SyncGroups_ListSyncDatabaseIds + /// Lists the SubResources for this . /// The instance the method will execute against. - /// The location of the database. - /// Whether or not to only get the latest backup for each database. - /// Whether to query against just live databases, just deleted databases, or all databases. + /// The name of the region where the resource is located. /// The cancellation token to use. /// is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static AsyncPageable GetLongTermRetentionBackupsByLocationAsync(this Subscription subscription, string locationName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) + public static AsyncPageable GetSyncDatabaseIdsSyncGroupsAsync(this Subscription subscription, string locationName, CancellationToken cancellationToken = default) { if (locationName == null) { @@ -473,14 +466,14 @@ public static AsyncPageable GetLongTermRetentionBac return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetLongTermRetentionBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - async Task> FirstPageFunc(int? pageSizeHint) + var restOperations = GetSyncGroupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByLocation"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetSyncDatabaseIdsSyncGroups"); scope.Start(); try { - var response = await restOperations.ListByLocationAsync(subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); + var response = await restOperations.ListSyncDatabaseIdsAsync(subscription.Id.SubscriptionId, locationName, cancellationToken: cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -489,13 +482,13 @@ async Task> FirstPageFunc(int? pageSizeHint) throw; } } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) + async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByLocation"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetSyncDatabaseIdsSyncGroups"); scope.Start(); try { - var response = await restOperations.ListByLocationNextPageAsync(nextLink, subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); + var response = await restOperations.ListSyncDatabaseIdsNextPageAsync(nextLink, subscription.Id.SubscriptionId, locationName, cancellationToken: cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -509,18 +502,16 @@ async Task> NextPageFunc(string nextLink, int? ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/syncDatabaseIds /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: LongTermRetentionBackups_ListByLocation - /// Lists the LongTermRetentionBackupData for this . + /// OperationId: SyncGroups_ListSyncDatabaseIds + /// Lists the SubResources for this . /// The instance the method will execute against. - /// The location of the database. - /// Whether or not to only get the latest backup for each database. - /// Whether to query against just live databases, just deleted databases, or all databases. + /// The name of the region where the resource is located. /// The cancellation token to use. /// is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static Pageable GetLongTermRetentionBackupsByLocation(this Subscription subscription, string locationName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) + public static Pageable GetSyncDatabaseIdsSyncGroups(this Subscription subscription, string locationName, CancellationToken cancellationToken = default) { if (locationName == null) { @@ -530,14 +521,14 @@ public static Pageable GetLongTermRetentionBackupsB return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetLongTermRetentionBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - Page FirstPageFunc(int? pageSizeHint) + var restOperations = GetSyncGroupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + Page FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByLocation"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetSyncDatabaseIdsSyncGroups"); scope.Start(); try { - var response = restOperations.ListByLocation(subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); + var response = restOperations.ListSyncDatabaseIds(subscription.Id.SubscriptionId, locationName, cancellationToken: cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -546,13 +537,13 @@ Page FirstPageFunc(int? pageSizeHint) throw; } } - Page NextPageFunc(string nextLink, int? pageSizeHint) + Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByLocation"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetSyncDatabaseIdsSyncGroups"); scope.Start(); try { - var response = restOperations.ListByLocationNextPage(nextLink, subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); + var response = restOperations.ListSyncDatabaseIdsNextPage(nextLink, subscription.Id.SubscriptionId, locationName, cancellationToken: cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -566,41 +557,27 @@ Page NextPageFunc(string nextLink, int? pageSizeHin ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/virtualClusters /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: LongTermRetentionBackups_ListByServer - /// Lists the LongTermRetentionBackupData for this . + /// OperationId: VirtualClusters_List + /// Lists the VirtualClusters for this . /// The instance the method will execute against. - /// The location of the database. - /// The name of the server. - /// Whether or not to only get the latest backup for each database. - /// Whether to query against just live databases, just deleted databases, or all databases. /// The cancellation token to use. - /// or is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static AsyncPageable GetLongTermRetentionBackupsByServerAsync(this Subscription subscription, string locationName, string longTermRetentionServerName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) + public static AsyncPageable GetVirtualClustersAsync(this Subscription subscription, CancellationToken cancellationToken = default) { - if (locationName == null) - { - throw new ArgumentNullException(nameof(locationName)); - } - if (longTermRetentionServerName == null) - { - throw new ArgumentNullException(nameof(longTermRetentionServerName)); - } - return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetLongTermRetentionBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - async Task> FirstPageFunc(int? pageSizeHint) + var restOperations = GetVirtualClustersRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByServer"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetVirtualClusters"); scope.Start(); try { - var response = await restOperations.ListByServerAsync(subscription.Id.SubscriptionId, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + var response = await restOperations.ListAsync(subscription.Id.SubscriptionId, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value.Select(value => new VirtualCluster(subscription, value)), response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -608,14 +585,14 @@ async Task> FirstPageFunc(int? pageSizeHint) throw; } } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) + async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByServer"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetVirtualClusters"); scope.Start(); try { - var response = await restOperations.ListByServerNextPageAsync(nextLink, subscription.Id.SubscriptionId, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + var response = await restOperations.ListNextPageAsync(nextLink, subscription.Id.SubscriptionId, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value.Select(value => new VirtualCluster(subscription, value)), response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -628,41 +605,27 @@ async Task> NextPageFunc(string nextLink, int? ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/virtualClusters /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: LongTermRetentionBackups_ListByServer - /// Lists the LongTermRetentionBackupData for this . + /// OperationId: VirtualClusters_List + /// Lists the VirtualClusters for this . /// The instance the method will execute against. - /// The location of the database. - /// The name of the server. - /// Whether or not to only get the latest backup for each database. - /// Whether to query against just live databases, just deleted databases, or all databases. /// The cancellation token to use. - /// or is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static Pageable GetLongTermRetentionBackupsByServer(this Subscription subscription, string locationName, string longTermRetentionServerName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) + public static Pageable GetVirtualClusters(this Subscription subscription, CancellationToken cancellationToken = default) { - if (locationName == null) - { - throw new ArgumentNullException(nameof(locationName)); - } - if (longTermRetentionServerName == null) - { - throw new ArgumentNullException(nameof(longTermRetentionServerName)); - } - return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetLongTermRetentionBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - Page FirstPageFunc(int? pageSizeHint) + var restOperations = GetVirtualClustersRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + Page FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByServer"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetVirtualClusters"); scope.Start(); try { - var response = restOperations.ListByServer(subscription.Id.SubscriptionId, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + var response = restOperations.List(subscription.Id.SubscriptionId, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value.Select(value => new VirtualCluster(subscription, value)), response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -670,14 +633,14 @@ Page FirstPageFunc(int? pageSizeHint) throw; } } - Page NextPageFunc(string nextLink, int? pageSizeHint) + Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByServer"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetVirtualClusters"); scope.Start(); try { - var response = restOperations.ListByServerNextPage(nextLink, subscription.Id.SubscriptionId, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + var response = restOperations.ListNextPage(nextLink, subscription.Id.SubscriptionId, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value.Select(value => new VirtualCluster(subscription, value)), response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -690,41 +653,56 @@ Page NextPageFunc(string nextLink, int? pageSizeHin ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups - /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: LongTermRetentionManagedInstanceBackups_ListByInstance - /// Lists the ManagedInstanceLongTermRetentionBackupData for this . + /// Filters the list of VirtualClusters for a represented as generic resources. /// The instance the method will execute against. - /// The location of the database. - /// The name of the managed instance. - /// Whether or not to only get the latest backup for each database. - /// Whether to query against just live databases, just deleted databases, or all databases. + /// The string to filter the list. + /// Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. + /// The number of results to return. /// The cancellation token to use. - /// or is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static AsyncPageable GetLongTermRetentionManagedInstanceBackupsByInstanceAsync(this Subscription subscription, string locationName, string managedInstanceName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) + public static AsyncPageable GetVirtualClustersAsGenericResourcesAsync(this Subscription subscription, string filter, string expand, int? top, CancellationToken cancellationToken = default) { - if (locationName == null) - { - throw new ArgumentNullException(nameof(locationName)); - } - if (managedInstanceName == null) - { - throw new ArgumentNullException(nameof(managedInstanceName)); - } + ResourceFilterCollection filters = new(VirtualCluster.ResourceType); + filters.SubstringFilter = filter; + return ResourceListOperations.GetAtContextAsync(subscription, filters, expand, top, cancellationToken); + } + + /// Filters the list of VirtualClusters for a represented as generic resources. + /// The instance the method will execute against. + /// The string to filter the list. + /// Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. + /// The number of results to return. + /// The cancellation token to use. + /// A collection of resource operations that may take multiple service requests to iterate over. + public static Pageable GetVirtualClustersAsGenericResources(this Subscription subscription, string filter, string expand, int? top, CancellationToken cancellationToken = default) + { + ResourceFilterCollection filters = new(VirtualCluster.ResourceType); + filters.SubstringFilter = filter; + return ResourceListOperations.GetAtContext(subscription, filters, expand, top, cancellationToken); + } + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/servers + /// ContextualPath: /subscriptions/{subscriptionId} + /// OperationId: Servers_List + /// Lists the SqlServers for this . + /// The instance the method will execute against. + /// The child resources to include in the response. + /// The cancellation token to use. + /// A collection of resource operations that may take multiple service requests to iterate over. + public static AsyncPageable GetServersAsync(this Subscription subscription, string expand = null, CancellationToken cancellationToken = default) + { return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetLongTermRetentionManagedInstanceBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - async Task> FirstPageFunc(int? pageSizeHint) + var restOperations = GetServersRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByInstance"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetServers"); scope.Start(); try { - var response = await restOperations.ListByInstanceAsync(subscription.Id.SubscriptionId, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + var response = await restOperations.ListAsync(subscription.Id.SubscriptionId, expand, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value.Select(value => new SqlServer(subscription, value)), response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -732,14 +710,14 @@ async Task> FirstPageFunc(int? throw; } } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) + async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByInstance"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetServers"); scope.Start(); try { - var response = await restOperations.ListByInstanceNextPageAsync(nextLink, subscription.Id.SubscriptionId, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + var response = await restOperations.ListNextPageAsync(nextLink, subscription.Id.SubscriptionId, expand, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value.Select(value => new SqlServer(subscription, value)), response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -752,41 +730,28 @@ async Task> NextPageFunc(string ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/servers /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: LongTermRetentionManagedInstanceBackups_ListByInstance - /// Lists the ManagedInstanceLongTermRetentionBackupData for this . + /// OperationId: Servers_List + /// Lists the SqlServers for this . /// The instance the method will execute against. - /// The location of the database. - /// The name of the managed instance. - /// Whether or not to only get the latest backup for each database. - /// Whether to query against just live databases, just deleted databases, or all databases. + /// The child resources to include in the response. /// The cancellation token to use. - /// or is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static Pageable GetLongTermRetentionManagedInstanceBackupsByInstance(this Subscription subscription, string locationName, string managedInstanceName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) + public static Pageable GetServers(this Subscription subscription, string expand = null, CancellationToken cancellationToken = default) { - if (locationName == null) - { - throw new ArgumentNullException(nameof(locationName)); - } - if (managedInstanceName == null) - { - throw new ArgumentNullException(nameof(managedInstanceName)); - } - return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetLongTermRetentionManagedInstanceBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - Page FirstPageFunc(int? pageSizeHint) + var restOperations = GetServersRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + Page FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByInstance"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetServers"); scope.Start(); try { - var response = restOperations.ListByInstance(subscription.Id.SubscriptionId, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + var response = restOperations.List(subscription.Id.SubscriptionId, expand, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value.Select(value => new SqlServer(subscription, value)), response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -794,14 +759,14 @@ Page FirstPageFunc(int? pageSizeHint throw; } } - Page NextPageFunc(string nextLink, int? pageSizeHint) + Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByInstance"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetServers"); scope.Start(); try { - var response = restOperations.ListByInstanceNextPage(nextLink, subscription.Id.SubscriptionId, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + var response = restOperations.ListNextPage(nextLink, subscription.Id.SubscriptionId, expand, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value.Select(value => new SqlServer(subscription, value)), response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -814,142 +779,134 @@ Page NextPageFunc(string nextLink, i ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups - /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: LongTermRetentionManagedInstanceBackups_ListByLocation - /// Lists the ManagedInstanceLongTermRetentionBackupData for this . + /// Filters the list of SqlServers for a represented as generic resources. /// The instance the method will execute against. - /// The location of the database. - /// Whether or not to only get the latest backup for each database. - /// Whether to query against just live databases, just deleted databases, or all databases. + /// The string to filter the list. + /// Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. + /// The number of results to return. /// The cancellation token to use. - /// is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static AsyncPageable GetLongTermRetentionManagedInstanceBackupsByLocationAsync(this Subscription subscription, string locationName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) + public static AsyncPageable GetSqlServersAsGenericResourcesAsync(this Subscription subscription, string filter, string expand, int? top, CancellationToken cancellationToken = default) { - if (locationName == null) + ResourceFilterCollection filters = new(SqlServer.ResourceType); + filters.SubstringFilter = filter; + return ResourceListOperations.GetAtContextAsync(subscription, filters, expand, top, cancellationToken); + } + + /// Filters the list of SqlServers for a represented as generic resources. + /// The instance the method will execute against. + /// The string to filter the list. + /// Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. + /// The number of results to return. + /// The cancellation token to use. + /// A collection of resource operations that may take multiple service requests to iterate over. + public static Pageable GetSqlServersAsGenericResources(this Subscription subscription, string filter, string expand, int? top, CancellationToken cancellationToken = default) + { + ResourceFilterCollection filters = new(SqlServer.ResourceType); + filters.SubstringFilter = filter; + return ResourceListOperations.GetAtContext(subscription, filters, expand, top, cancellationToken); + } + + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/checkNameAvailability + /// ContextualPath: /subscriptions/{subscriptionId} + /// OperationId: Servers_CheckNameAvailability + /// Determines whether a resource can be created with the specified name. + /// The instance the method will execute against. + /// The name availability request parameters. + /// The cancellation token to use. + /// is null. + public static async Task> CheckNameAvailabilityServerAsync(this Subscription subscription, CheckNameAvailabilityRequest parameters, CancellationToken cancellationToken = default) + { + if (parameters == null) { - throw new ArgumentNullException(nameof(locationName)); + throw new ArgumentNullException(nameof(parameters)); } - return subscription.UseClientContext((baseUri, credential, options, pipeline) => + return await subscription.UseClientContext(async (baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetLongTermRetentionManagedInstanceBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - async Task> FirstPageFunc(int? pageSizeHint) + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.CheckNameAvailabilityServer"); + scope.Start(); + try { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByLocation"); - scope.Start(); - try - { - var response = await restOperations.ListByLocationAsync(subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } + var restOperations = GetServersRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + var response = await restOperations.CheckNameAvailabilityAsync(subscription.Id.SubscriptionId, parameters, cancellationToken).ConfigureAwait(false); + return response; } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) + catch (Exception e) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByLocation"); - scope.Start(); - try - { - var response = await restOperations.ListByLocationNextPageAsync(nextLink, subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } + scope.Failed(e); + throw; } - return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); } - ); + ).ConfigureAwait(false); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/checkNameAvailability /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: LongTermRetentionManagedInstanceBackups_ListByLocation - /// Lists the ManagedInstanceLongTermRetentionBackupData for this . + /// OperationId: Servers_CheckNameAvailability + /// Determines whether a resource can be created with the specified name. /// The instance the method will execute against. - /// The location of the database. - /// Whether or not to only get the latest backup for each database. - /// Whether to query against just live databases, just deleted databases, or all databases. + /// The name availability request parameters. /// The cancellation token to use. - /// is null. - /// A collection of resource operations that may take multiple service requests to iterate over. - public static Pageable GetLongTermRetentionManagedInstanceBackupsByLocation(this Subscription subscription, string locationName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) + /// is null. + public static Response CheckNameAvailabilityServer(this Subscription subscription, CheckNameAvailabilityRequest parameters, CancellationToken cancellationToken = default) { - if (locationName == null) + if (parameters == null) { - throw new ArgumentNullException(nameof(locationName)); + throw new ArgumentNullException(nameof(parameters)); } return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetLongTermRetentionManagedInstanceBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - Page FirstPageFunc(int? pageSizeHint) + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.CheckNameAvailabilityServer"); + scope.Start(); + try { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByLocation"); - scope.Start(); - try - { - var response = restOperations.ListByLocation(subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } + var restOperations = GetServersRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + var response = restOperations.CheckNameAvailability(subscription.Id.SubscriptionId, parameters, cancellationToken); + return response; } - Page NextPageFunc(string nextLink, int? pageSizeHint) + catch (Exception e) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByLocation"); - scope.Start(); - try - { - var response = restOperations.ListByLocationNextPage(nextLink, subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } + scope.Failed(e); + throw; } - return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); } ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/managedInstances + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: ManagedInstances_List - /// Lists the ManagedInstances for this . + /// OperationId: LongTermRetentionBackups_ListByLocation + /// Lists the LongTermRetentionBackupData for this . /// The instance the method will execute against. - /// The child resources to include in the response. + /// The location of the database. + /// Whether or not to only get the latest backup for each database. + /// Whether to query against just live databases, just deleted databases, or all databases. /// The cancellation token to use. + /// is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static AsyncPageable GetManagedInstancesAsync(this Subscription subscription, string expand = null, CancellationToken cancellationToken = default) + public static AsyncPageable GetLongTermRetentionBackupsByLocationAsync(this Subscription subscription, string locationName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) { + if (locationName == null) + { + throw new ArgumentNullException(nameof(locationName)); + } + return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetManagedInstancesRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - async Task> FirstPageFunc(int? pageSizeHint) + var restOperations = GetLongTermRetentionBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetManagedInstances"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByLocation"); scope.Start(); try { - var response = await restOperations.ListAsync(subscription.Id.SubscriptionId, expand, cancellationToken: cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value.Select(value => new ManagedInstance(subscription, value)), response.Value.NextLink, response.GetRawResponse()); + var response = await restOperations.ListByLocationAsync(subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -957,14 +914,14 @@ async Task> FirstPageFunc(int? pageSizeHint) throw; } } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) + async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetManagedInstances"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByLocation"); scope.Start(); try { - var response = await restOperations.ListNextPageAsync(nextLink, subscription.Id.SubscriptionId, expand, cancellationToken: cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value.Select(value => new ManagedInstance(subscription, value)), response.Value.NextLink, response.GetRawResponse()); + var response = await restOperations.ListByLocationNextPageAsync(nextLink, subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -977,28 +934,36 @@ async Task> NextPageFunc(string nextLink, int? pageSizeHin ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/managedInstances + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionBackups /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: ManagedInstances_List - /// Lists the ManagedInstances for this . + /// OperationId: LongTermRetentionBackups_ListByLocation + /// Lists the LongTermRetentionBackupData for this . /// The instance the method will execute against. - /// The child resources to include in the response. + /// The location of the database. + /// Whether or not to only get the latest backup for each database. + /// Whether to query against just live databases, just deleted databases, or all databases. /// The cancellation token to use. + /// is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static Pageable GetManagedInstances(this Subscription subscription, string expand = null, CancellationToken cancellationToken = default) + public static Pageable GetLongTermRetentionBackupsByLocation(this Subscription subscription, string locationName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) { + if (locationName == null) + { + throw new ArgumentNullException(nameof(locationName)); + } + return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetManagedInstancesRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - Page FirstPageFunc(int? pageSizeHint) + var restOperations = GetLongTermRetentionBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + Page FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetManagedInstances"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByLocation"); scope.Start(); try { - var response = restOperations.List(subscription.Id.SubscriptionId, expand, cancellationToken: cancellationToken); - return Page.FromValues(response.Value.Value.Select(value => new ManagedInstance(subscription, value)), response.Value.NextLink, response.GetRawResponse()); + var response = restOperations.ListByLocation(subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -1006,14 +971,14 @@ Page FirstPageFunc(int? pageSizeHint) throw; } } - Page NextPageFunc(string nextLink, int? pageSizeHint) + Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetManagedInstances"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByLocation"); scope.Start(); try { - var response = restOperations.ListNextPage(nextLink, subscription.Id.SubscriptionId, expand, cancellationToken: cancellationToken); - return Page.FromValues(response.Value.Value.Select(value => new ManagedInstance(subscription, value)), response.Value.NextLink, response.GetRawResponse()); + var response = restOperations.ListByLocationNextPage(nextLink, subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -1026,61 +991,40 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) ); } - /// Filters the list of ManagedInstances for a represented as generic resources. - /// The instance the method will execute against. - /// The string to filter the list. - /// Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. - /// The number of results to return. - /// The cancellation token to use. - /// A collection of resource operations that may take multiple service requests to iterate over. - public static AsyncPageable GetManagedInstancesAsGenericResourcesAsync(this Subscription subscription, string filter, string expand, int? top, CancellationToken cancellationToken = default) - { - ResourceFilterCollection filters = new(ManagedInstance.ResourceType); - filters.SubstringFilter = filter; - return ResourceListOperations.GetAtContextAsync(subscription, filters, expand, top, cancellationToken); - } - - /// Filters the list of ManagedInstances for a represented as generic resources. - /// The instance the method will execute against. - /// The string to filter the list. - /// Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. - /// The number of results to return. - /// The cancellation token to use. - /// A collection of resource operations that may take multiple service requests to iterate over. - public static Pageable GetManagedInstancesAsGenericResources(this Subscription subscription, string filter, string expand, int? top, CancellationToken cancellationToken = default) - { - ResourceFilterCollection filters = new(ManagedInstance.ResourceType); - filters.SubstringFilter = filter; - return ResourceListOperations.GetAtContext(subscription, filters, expand, top, cancellationToken); - } - - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/operationsHealth + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: OperationsHealth_ListByLocation - /// Lists the OperationsHealths for this . + /// OperationId: LongTermRetentionBackups_ListByServer + /// Lists the LongTermRetentionBackupData for this . /// The instance the method will execute against. - /// The name of the region where the resource is located. + /// The location of the database. + /// The name of the server. + /// Whether or not to only get the latest backup for each database. + /// Whether to query against just live databases, just deleted databases, or all databases. /// The cancellation token to use. - /// is null. + /// or is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static AsyncPageable GetOperationsHealthsByLocationAsync(this Subscription subscription, string locationName, CancellationToken cancellationToken = default) + public static AsyncPageable GetLongTermRetentionBackupsByServerAsync(this Subscription subscription, string locationName, string longTermRetentionServerName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) { if (locationName == null) { throw new ArgumentNullException(nameof(locationName)); } + if (longTermRetentionServerName == null) + { + throw new ArgumentNullException(nameof(longTermRetentionServerName)); + } return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetOperationsHealthRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - async Task> FirstPageFunc(int? pageSizeHint) + var restOperations = GetLongTermRetentionBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetOperationsHealthsByLocation"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByServer"); scope.Start(); try { - var response = await restOperations.ListByLocationAsync(subscription.Id.SubscriptionId, locationName, cancellationToken: cancellationToken).ConfigureAwait(false); + var response = await restOperations.ListByServerAsync(subscription.Id.SubscriptionId, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -1089,13 +1033,13 @@ async Task> FirstPageFunc(int? pageSizeHint) throw; } } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) + async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetOperationsHealthsByLocation"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByServer"); scope.Start(); try { - var response = await restOperations.ListByLocationNextPageAsync(nextLink, subscription.Id.SubscriptionId, locationName, cancellationToken: cancellationToken).ConfigureAwait(false); + var response = await restOperations.ListByServerNextPageAsync(nextLink, subscription.Id.SubscriptionId, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -1109,33 +1053,40 @@ async Task> NextPageFunc(string nextLink, int? pageSizeHi ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/operationsHealth + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionServers/{longTermRetentionServerName}/longTermRetentionBackups /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: OperationsHealth_ListByLocation - /// Lists the OperationsHealths for this . + /// OperationId: LongTermRetentionBackups_ListByServer + /// Lists the LongTermRetentionBackupData for this . /// The instance the method will execute against. - /// The name of the region where the resource is located. + /// The location of the database. + /// The name of the server. + /// Whether or not to only get the latest backup for each database. + /// Whether to query against just live databases, just deleted databases, or all databases. /// The cancellation token to use. - /// is null. + /// or is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static Pageable GetOperationsHealthsByLocation(this Subscription subscription, string locationName, CancellationToken cancellationToken = default) + public static Pageable GetLongTermRetentionBackupsByServer(this Subscription subscription, string locationName, string longTermRetentionServerName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) { if (locationName == null) { throw new ArgumentNullException(nameof(locationName)); } + if (longTermRetentionServerName == null) + { + throw new ArgumentNullException(nameof(longTermRetentionServerName)); + } return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetOperationsHealthRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - Page FirstPageFunc(int? pageSizeHint) + var restOperations = GetLongTermRetentionBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + Page FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetOperationsHealthsByLocation"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByServer"); scope.Start(); try { - var response = restOperations.ListByLocation(subscription.Id.SubscriptionId, locationName, cancellationToken: cancellationToken); + var response = restOperations.ListByServer(subscription.Id.SubscriptionId, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -1144,13 +1095,13 @@ Page FirstPageFunc(int? pageSizeHint) throw; } } - Page NextPageFunc(string nextLink, int? pageSizeHint) + Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetOperationsHealthsByLocation"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionBackupsByServer"); scope.Start(); try { - var response = restOperations.ListByLocationNextPage(nextLink, subscription.Id.SubscriptionId, locationName, cancellationToken: cancellationToken); + var response = restOperations.ListByServerNextPage(nextLink, subscription.Id.SubscriptionId, locationName, longTermRetentionServerName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -1164,33 +1115,40 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/syncDatabaseIds + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: SyncGroups_ListSyncDatabaseIds - /// Lists the SubResources for this . + /// OperationId: LongTermRetentionManagedInstanceBackups_ListByInstance + /// Lists the ManagedInstanceLongTermRetentionBackupData for this . /// The instance the method will execute against. - /// The name of the region where the resource is located. + /// The location of the database. + /// The name of the managed instance. + /// Whether or not to only get the latest backup for each database. + /// Whether to query against just live databases, just deleted databases, or all databases. /// The cancellation token to use. - /// is null. + /// or is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static AsyncPageable GetSyncDatabaseIdsSyncGroupsAsync(this Subscription subscription, string locationName, CancellationToken cancellationToken = default) + public static AsyncPageable GetLongTermRetentionManagedInstanceBackupsByInstanceAsync(this Subscription subscription, string locationName, string managedInstanceName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) { if (locationName == null) { throw new ArgumentNullException(nameof(locationName)); } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetSyncGroupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - async Task> FirstPageFunc(int? pageSizeHint) + var restOperations = GetLongTermRetentionManagedInstanceBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetSyncDatabaseIdsSyncGroups"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByInstance"); scope.Start(); try { - var response = await restOperations.ListSyncDatabaseIdsAsync(subscription.Id.SubscriptionId, locationName, cancellationToken: cancellationToken).ConfigureAwait(false); + var response = await restOperations.ListByInstanceAsync(subscription.Id.SubscriptionId, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -1199,13 +1157,13 @@ async Task> FirstPageFunc(int? pageSizeHint) throw; } } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) + async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetSyncDatabaseIdsSyncGroups"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByInstance"); scope.Start(); try { - var response = await restOperations.ListSyncDatabaseIdsNextPageAsync(nextLink, subscription.Id.SubscriptionId, locationName, cancellationToken: cancellationToken).ConfigureAwait(false); + var response = await restOperations.ListByInstanceNextPageAsync(nextLink, subscription.Id.SubscriptionId, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -1219,33 +1177,40 @@ async Task> NextPageFunc(string nextLink, int? pageSizeHint) ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/syncDatabaseIds + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstances/{managedInstanceName}/longTermRetentionManagedInstanceBackups /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: SyncGroups_ListSyncDatabaseIds - /// Lists the SubResources for this . + /// OperationId: LongTermRetentionManagedInstanceBackups_ListByInstance + /// Lists the ManagedInstanceLongTermRetentionBackupData for this . /// The instance the method will execute against. - /// The name of the region where the resource is located. + /// The location of the database. + /// The name of the managed instance. + /// Whether or not to only get the latest backup for each database. + /// Whether to query against just live databases, just deleted databases, or all databases. /// The cancellation token to use. - /// is null. + /// or is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static Pageable GetSyncDatabaseIdsSyncGroups(this Subscription subscription, string locationName, CancellationToken cancellationToken = default) + public static Pageable GetLongTermRetentionManagedInstanceBackupsByInstance(this Subscription subscription, string locationName, string managedInstanceName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) { if (locationName == null) { throw new ArgumentNullException(nameof(locationName)); } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetSyncGroupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - Page FirstPageFunc(int? pageSizeHint) + var restOperations = GetLongTermRetentionManagedInstanceBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + Page FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetSyncDatabaseIdsSyncGroups"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByInstance"); scope.Start(); try { - var response = restOperations.ListSyncDatabaseIds(subscription.Id.SubscriptionId, locationName, cancellationToken: cancellationToken); + var response = restOperations.ListByInstance(subscription.Id.SubscriptionId, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -1254,13 +1219,13 @@ Page FirstPageFunc(int? pageSizeHint) throw; } } - Page NextPageFunc(string nextLink, int? pageSizeHint) + Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetSyncDatabaseIdsSyncGroups"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByInstance"); scope.Start(); try { - var response = restOperations.ListSyncDatabaseIdsNextPage(nextLink, subscription.Id.SubscriptionId, locationName, cancellationToken: cancellationToken); + var response = restOperations.ListByInstanceNextPage(nextLink, subscription.Id.SubscriptionId, locationName, managedInstanceName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -1274,27 +1239,36 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/virtualClusters + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: VirtualClusters_List - /// Lists the VirtualClusters for this . + /// OperationId: LongTermRetentionManagedInstanceBackups_ListByLocation + /// Lists the ManagedInstanceLongTermRetentionBackupData for this . /// The instance the method will execute against. + /// The location of the database. + /// Whether or not to only get the latest backup for each database. + /// Whether to query against just live databases, just deleted databases, or all databases. /// The cancellation token to use. + /// is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static AsyncPageable GetVirtualClustersAsync(this Subscription subscription, CancellationToken cancellationToken = default) + public static AsyncPageable GetLongTermRetentionManagedInstanceBackupsByLocationAsync(this Subscription subscription, string locationName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) { + if (locationName == null) + { + throw new ArgumentNullException(nameof(locationName)); + } + return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetVirtualClustersRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - async Task> FirstPageFunc(int? pageSizeHint) + var restOperations = GetLongTermRetentionManagedInstanceBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetVirtualClusters"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByLocation"); scope.Start(); try { - var response = await restOperations.ListAsync(subscription.Id.SubscriptionId, cancellationToken: cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value.Select(value => new VirtualCluster(subscription, value)), response.Value.NextLink, response.GetRawResponse()); + var response = await restOperations.ListByLocationAsync(subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -1302,14 +1276,14 @@ async Task> FirstPageFunc(int? pageSizeHint) throw; } } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) + async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetVirtualClusters"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByLocation"); scope.Start(); try { - var response = await restOperations.ListNextPageAsync(nextLink, subscription.Id.SubscriptionId, cancellationToken: cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value.Select(value => new VirtualCluster(subscription, value)), response.Value.NextLink, response.GetRawResponse()); + var response = await restOperations.ListByLocationNextPageAsync(nextLink, subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -1322,27 +1296,36 @@ async Task> NextPageFunc(string nextLink, int? pageSizeHint ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/virtualClusters + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/longTermRetentionManagedInstanceBackups /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: VirtualClusters_List - /// Lists the VirtualClusters for this . + /// OperationId: LongTermRetentionManagedInstanceBackups_ListByLocation + /// Lists the ManagedInstanceLongTermRetentionBackupData for this . /// The instance the method will execute against. + /// The location of the database. + /// Whether or not to only get the latest backup for each database. + /// Whether to query against just live databases, just deleted databases, or all databases. /// The cancellation token to use. + /// is null. /// A collection of resource operations that may take multiple service requests to iterate over. - public static Pageable GetVirtualClusters(this Subscription subscription, CancellationToken cancellationToken = default) + public static Pageable GetLongTermRetentionManagedInstanceBackupsByLocation(this Subscription subscription, string locationName, bool? onlyLatestPerDatabase = null, DatabaseState? databaseState = null, CancellationToken cancellationToken = default) { + if (locationName == null) + { + throw new ArgumentNullException(nameof(locationName)); + } + return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetVirtualClustersRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - Page FirstPageFunc(int? pageSizeHint) + var restOperations = GetLongTermRetentionManagedInstanceBackupsRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + Page FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetVirtualClusters"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByLocation"); scope.Start(); try { - var response = restOperations.List(subscription.Id.SubscriptionId, cancellationToken: cancellationToken); - return Page.FromValues(response.Value.Value.Select(value => new VirtualCluster(subscription, value)), response.Value.NextLink, response.GetRawResponse()); + var response = restOperations.ListByLocation(subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -1350,14 +1333,14 @@ Page FirstPageFunc(int? pageSizeHint) throw; } } - Page NextPageFunc(string nextLink, int? pageSizeHint) + Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetVirtualClusters"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetLongTermRetentionManagedInstanceBackupsByLocation"); scope.Start(); try { - var response = restOperations.ListNextPage(nextLink, subscription.Id.SubscriptionId, cancellationToken: cancellationToken); - return Page.FromValues(response.Value.Value.Select(value => new VirtualCluster(subscription, value)), response.Value.NextLink, response.GetRawResponse()); + var response = restOperations.ListByLocationNextPage(nextLink, subscription.Id.SubscriptionId, locationName, onlyLatestPerDatabase, databaseState, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -1370,56 +1353,28 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) ); } - /// Filters the list of VirtualClusters for a represented as generic resources. - /// The instance the method will execute against. - /// The string to filter the list. - /// Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. - /// The number of results to return. - /// The cancellation token to use. - /// A collection of resource operations that may take multiple service requests to iterate over. - public static AsyncPageable GetVirtualClustersAsGenericResourcesAsync(this Subscription subscription, string filter, string expand, int? top, CancellationToken cancellationToken = default) - { - ResourceFilterCollection filters = new(VirtualCluster.ResourceType); - filters.SubstringFilter = filter; - return ResourceListOperations.GetAtContextAsync(subscription, filters, expand, top, cancellationToken); - } - - /// Filters the list of VirtualClusters for a represented as generic resources. - /// The instance the method will execute against. - /// The string to filter the list. - /// Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. - /// The number of results to return. - /// The cancellation token to use. - /// A collection of resource operations that may take multiple service requests to iterate over. - public static Pageable GetVirtualClustersAsGenericResources(this Subscription subscription, string filter, string expand, int? top, CancellationToken cancellationToken = default) - { - ResourceFilterCollection filters = new(VirtualCluster.ResourceType); - filters.SubstringFilter = filter; - return ResourceListOperations.GetAtContext(subscription, filters, expand, top, cancellationToken); - } - - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/servers + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/managedInstances /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: Servers_List - /// Lists the SqlServers for this . + /// OperationId: ManagedInstances_List + /// Lists the ManagedInstances for this . /// The instance the method will execute against. /// The child resources to include in the response. /// The cancellation token to use. /// A collection of resource operations that may take multiple service requests to iterate over. - public static AsyncPageable GetServersAsync(this Subscription subscription, string expand = null, CancellationToken cancellationToken = default) + public static AsyncPageable GetManagedInstancesAsync(this Subscription subscription, string expand = null, CancellationToken cancellationToken = default) { return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetServersRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - async Task> FirstPageFunc(int? pageSizeHint) + var restOperations = GetManagedInstancesRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetServers"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetManagedInstances"); scope.Start(); try { var response = await restOperations.ListAsync(subscription.Id.SubscriptionId, expand, cancellationToken: cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value.Select(value => new SqlServer(subscription, value)), response.Value.NextLink, response.GetRawResponse()); + return Page.FromValues(response.Value.Value.Select(value => new ManagedInstance(subscription, value)), response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -1427,14 +1382,14 @@ async Task> FirstPageFunc(int? pageSizeHint) throw; } } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) + async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetServers"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetManagedInstances"); scope.Start(); try { var response = await restOperations.ListNextPageAsync(nextLink, subscription.Id.SubscriptionId, expand, cancellationToken: cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value.Select(value => new SqlServer(subscription, value)), response.Value.NextLink, response.GetRawResponse()); + return Page.FromValues(response.Value.Value.Select(value => new ManagedInstance(subscription, value)), response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -1447,28 +1402,28 @@ async Task> NextPageFunc(string nextLink, int? pageSizeHint) ); } - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/servers + /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/managedInstances /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: Servers_List - /// Lists the SqlServers for this . + /// OperationId: ManagedInstances_List + /// Lists the ManagedInstances for this . /// The instance the method will execute against. /// The child resources to include in the response. /// The cancellation token to use. /// A collection of resource operations that may take multiple service requests to iterate over. - public static Pageable GetServers(this Subscription subscription, string expand = null, CancellationToken cancellationToken = default) + public static Pageable GetManagedInstances(this Subscription subscription, string expand = null, CancellationToken cancellationToken = default) { return subscription.UseClientContext((baseUri, credential, options, pipeline) => { var clientDiagnostics = new ClientDiagnostics(options); - var restOperations = GetServersRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - Page FirstPageFunc(int? pageSizeHint) + var restOperations = GetManagedInstancesRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); + Page FirstPageFunc(int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetServers"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetManagedInstances"); scope.Start(); try { var response = restOperations.List(subscription.Id.SubscriptionId, expand, cancellationToken: cancellationToken); - return Page.FromValues(response.Value.Value.Select(value => new SqlServer(subscription, value)), response.Value.NextLink, response.GetRawResponse()); + return Page.FromValues(response.Value.Value.Select(value => new ManagedInstance(subscription, value)), response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -1476,14 +1431,14 @@ Page FirstPageFunc(int? pageSizeHint) throw; } } - Page NextPageFunc(string nextLink, int? pageSizeHint) + Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetServers"); + using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.GetManagedInstances"); scope.Start(); try { var response = restOperations.ListNextPage(nextLink, subscription.Id.SubscriptionId, expand, cancellationToken: cancellationToken); - return Page.FromValues(response.Value.Value.Select(value => new SqlServer(subscription, value)), response.Value.NextLink, response.GetRawResponse()); + return Page.FromValues(response.Value.Value.Select(value => new ManagedInstance(subscription, value)), response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) { @@ -1496,102 +1451,32 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) ); } - /// Filters the list of SqlServers for a represented as generic resources. + /// Filters the list of ManagedInstances for a represented as generic resources. /// The instance the method will execute against. /// The string to filter the list. /// Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. /// The number of results to return. /// The cancellation token to use. /// A collection of resource operations that may take multiple service requests to iterate over. - public static AsyncPageable GetSqlServersAsGenericResourcesAsync(this Subscription subscription, string filter, string expand, int? top, CancellationToken cancellationToken = default) + public static AsyncPageable GetManagedInstancesAsGenericResourcesAsync(this Subscription subscription, string filter, string expand, int? top, CancellationToken cancellationToken = default) { - ResourceFilterCollection filters = new(SqlServer.ResourceType); + ResourceFilterCollection filters = new(ManagedInstance.ResourceType); filters.SubstringFilter = filter; return ResourceListOperations.GetAtContextAsync(subscription, filters, expand, top, cancellationToken); } - /// Filters the list of SqlServers for a represented as generic resources. + /// Filters the list of ManagedInstances for a represented as generic resources. /// The instance the method will execute against. /// The string to filter the list. /// Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. /// The number of results to return. /// The cancellation token to use. /// A collection of resource operations that may take multiple service requests to iterate over. - public static Pageable GetSqlServersAsGenericResources(this Subscription subscription, string filter, string expand, int? top, CancellationToken cancellationToken = default) + public static Pageable GetManagedInstancesAsGenericResources(this Subscription subscription, string filter, string expand, int? top, CancellationToken cancellationToken = default) { - ResourceFilterCollection filters = new(SqlServer.ResourceType); + ResourceFilterCollection filters = new(ManagedInstance.ResourceType); filters.SubstringFilter = filter; return ResourceListOperations.GetAtContext(subscription, filters, expand, top, cancellationToken); } - - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/checkNameAvailability - /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: Servers_CheckNameAvailability - /// Determines whether a resource can be created with the specified name. - /// The instance the method will execute against. - /// The name availability request parameters. - /// The cancellation token to use. - /// is null. - public static async Task> CheckNameAvailabilityServerAsync(this Subscription subscription, CheckNameAvailabilityRequest parameters, CancellationToken cancellationToken = default) - { - if (parameters == null) - { - throw new ArgumentNullException(nameof(parameters)); - } - - return await subscription.UseClientContext(async (baseUri, credential, options, pipeline) => - { - var clientDiagnostics = new ClientDiagnostics(options); - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.CheckNameAvailabilityServer"); - scope.Start(); - try - { - var restOperations = GetServersRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - var response = await restOperations.CheckNameAvailabilityAsync(subscription.Id.SubscriptionId, parameters, cancellationToken).ConfigureAwait(false); - return response; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - ).ConfigureAwait(false); - } - - /// RequestPath: /subscriptions/{subscriptionId}/providers/Microsoft.Sql/checkNameAvailability - /// ContextualPath: /subscriptions/{subscriptionId} - /// OperationId: Servers_CheckNameAvailability - /// Determines whether a resource can be created with the specified name. - /// The instance the method will execute against. - /// The name availability request parameters. - /// The cancellation token to use. - /// is null. - public static Response CheckNameAvailabilityServer(this Subscription subscription, CheckNameAvailabilityRequest parameters, CancellationToken cancellationToken = default) - { - if (parameters == null) - { - throw new ArgumentNullException(nameof(parameters)); - } - - return subscription.UseClientContext((baseUri, credential, options, pipeline) => - { - var clientDiagnostics = new ClientDiagnostics(options); - using var scope = clientDiagnostics.CreateScope("SubscriptionExtensions.CheckNameAvailabilityServer"); - scope.Start(); - try - { - var restOperations = GetServersRestOperations(clientDiagnostics, credential, options, pipeline, baseUri); - var response = restOperations.CheckNameAvailability(subscription.Id.SubscriptionId, parameters, cancellationToken); - return response; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - ); - } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/InstancePool.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/InstancePool.cs index b0da936f99e5..ae1e85cd7742 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/InstancePool.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/InstancePool.cs @@ -30,8 +30,8 @@ public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, } private readonly ClientDiagnostics _clientDiagnostics; private readonly InstancePoolsRestOperations _instancePoolsRestClient; - private readonly ManagedInstancesRestOperations _managedInstancesRestClient; private readonly UsagesRestOperations _usagesRestClient; + private readonly ManagedInstancesRestOperations _managedInstancesRestClient; private readonly InstancePoolData _data; /// Initializes a new instance of the class for mocking. @@ -48,8 +48,8 @@ internal InstancePool(ArmResource options, InstancePoolData resource) : base(opt _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _instancePoolsRestClient = new InstancePoolsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); - _managedInstancesRestClient = new ManagedInstancesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); _usagesRestClient = new UsagesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); + _managedInstancesRestClient = new ManagedInstancesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); #if DEBUG ValidateResourceId(Id); #endif @@ -62,8 +62,8 @@ internal InstancePool(ArmResource options, ResourceIdentifier id) : base(options { _clientDiagnostics = new ClientDiagnostics(ClientOptions); _instancePoolsRestClient = new InstancePoolsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); - _managedInstancesRestClient = new ManagedInstancesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); _usagesRestClient = new UsagesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); + _managedInstancesRestClient = new ManagedInstancesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); #if DEBUG ValidateResourceId(Id); #endif @@ -79,8 +79,8 @@ internal InstancePool(ArmClientOptions clientOptions, TokenCredential credential { _clientDiagnostics = new ClientDiagnostics(ClientOptions); _instancePoolsRestClient = new InstancePoolsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); - _managedInstancesRestClient = new ManagedInstancesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); _usagesRestClient = new UsagesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); + _managedInstancesRestClient = new ManagedInstancesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); #if DEBUG ValidateResourceId(Id); #endif @@ -458,22 +458,22 @@ public virtual InstancePoolUpdateOperation Update(InstancePoolUpdate parameters, } } - /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/managedInstances + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/usages /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName} - /// OperationId: ManagedInstances_ListByInstancePool - /// Gets a list of all managed instances in an instance pool. - /// The child resources to include in the response. + /// OperationId: Usages_ListByInstancePool + /// Gets all instance pool usage metrics. + /// Optional request parameter to include managed instance usages within the instance pool. /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetManagedInstancesAsync(string expand = null, CancellationToken cancellationToken = default) + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetUsagesAsync(bool? expandChildren = null, CancellationToken cancellationToken = default) { - async Task> FirstPageFunc(int? pageSizeHint) + async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("InstancePool.GetManagedInstances"); + using var scope = _clientDiagnostics.CreateScope("InstancePool.GetUsages"); scope.Start(); try { - var response = await _managedInstancesRestClient.ListByInstancePoolAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken: cancellationToken).ConfigureAwait(false); + var response = await _usagesRestClient.ListByInstancePoolAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expandChildren, cancellationToken: cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -482,13 +482,13 @@ async Task> FirstPageFunc(int? pageSizeHint) throw; } } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) + async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("InstancePool.GetManagedInstances"); + using var scope = _clientDiagnostics.CreateScope("InstancePool.GetUsages"); scope.Start(); try { - var response = await _managedInstancesRestClient.ListByInstancePoolNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken: cancellationToken).ConfigureAwait(false); + var response = await _usagesRestClient.ListByInstancePoolNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expandChildren, cancellationToken: cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -500,22 +500,22 @@ async Task> NextPageFunc(string nextLink, int? pageSiz return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); } - /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/managedInstances + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/usages /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName} - /// OperationId: ManagedInstances_ListByInstancePool - /// Gets a list of all managed instances in an instance pool. - /// The child resources to include in the response. + /// OperationId: Usages_ListByInstancePool + /// Gets all instance pool usage metrics. + /// Optional request parameter to include managed instance usages within the instance pool. /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetManagedInstances(string expand = null, CancellationToken cancellationToken = default) + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetUsages(bool? expandChildren = null, CancellationToken cancellationToken = default) { - Page FirstPageFunc(int? pageSizeHint) + Page FirstPageFunc(int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("InstancePool.GetManagedInstances"); + using var scope = _clientDiagnostics.CreateScope("InstancePool.GetUsages"); scope.Start(); try { - var response = _managedInstancesRestClient.ListByInstancePool(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken: cancellationToken); + var response = _usagesRestClient.ListByInstancePool(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expandChildren, cancellationToken: cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -524,13 +524,13 @@ Page FirstPageFunc(int? pageSizeHint) throw; } } - Page NextPageFunc(string nextLink, int? pageSizeHint) + Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("InstancePool.GetManagedInstances"); + using var scope = _clientDiagnostics.CreateScope("InstancePool.GetUsages"); scope.Start(); try { - var response = _managedInstancesRestClient.ListByInstancePoolNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken: cancellationToken); + var response = _usagesRestClient.ListByInstancePoolNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expandChildren, cancellationToken: cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -542,22 +542,22 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); } - /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/usages + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/managedInstances /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName} - /// OperationId: Usages_ListByInstancePool - /// Gets all instance pool usage metrics. - /// Optional request parameter to include managed instance usages within the instance pool. + /// OperationId: ManagedInstances_ListByInstancePool + /// Gets a list of all managed instances in an instance pool. + /// The child resources to include in the response. /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetUsagesAsync(bool? expandChildren = null, CancellationToken cancellationToken = default) + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetManagedInstancesAsync(string expand = null, CancellationToken cancellationToken = default) { - async Task> FirstPageFunc(int? pageSizeHint) + async Task> FirstPageFunc(int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("InstancePool.GetUsages"); + using var scope = _clientDiagnostics.CreateScope("InstancePool.GetManagedInstances"); scope.Start(); try { - var response = await _usagesRestClient.ListByInstancePoolAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expandChildren, cancellationToken: cancellationToken).ConfigureAwait(false); + var response = await _managedInstancesRestClient.ListByInstancePoolAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken: cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -566,13 +566,13 @@ async Task> FirstPageFunc(int? pageSizeHint) throw; } } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) + async Task> NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("InstancePool.GetUsages"); + using var scope = _clientDiagnostics.CreateScope("InstancePool.GetManagedInstances"); scope.Start(); try { - var response = await _usagesRestClient.ListByInstancePoolNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expandChildren, cancellationToken: cancellationToken).ConfigureAwait(false); + var response = await _managedInstancesRestClient.ListByInstancePoolNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken: cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -584,22 +584,22 @@ async Task> NextPageFunc(string nextLink, int? pageSizeH return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); } - /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/usages + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/managedInstances /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName} - /// OperationId: Usages_ListByInstancePool - /// Gets all instance pool usage metrics. - /// Optional request parameter to include managed instance usages within the instance pool. + /// OperationId: ManagedInstances_ListByInstancePool + /// Gets a list of all managed instances in an instance pool. + /// The child resources to include in the response. /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetUsages(bool? expandChildren = null, CancellationToken cancellationToken = default) + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetManagedInstances(string expand = null, CancellationToken cancellationToken = default) { - Page FirstPageFunc(int? pageSizeHint) + Page FirstPageFunc(int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("InstancePool.GetUsages"); + using var scope = _clientDiagnostics.CreateScope("InstancePool.GetManagedInstances"); scope.Start(); try { - var response = _usagesRestClient.ListByInstancePool(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expandChildren, cancellationToken: cancellationToken); + var response = _managedInstancesRestClient.ListByInstancePool(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken: cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -608,13 +608,13 @@ Page FirstPageFunc(int? pageSizeHint) throw; } } - Page NextPageFunc(string nextLink, int? pageSizeHint) + Page NextPageFunc(string nextLink, int? pageSizeHint) { - using var scope = _clientDiagnostics.CreateScope("InstancePool.GetUsages"); + using var scope = _clientDiagnostics.CreateScope("InstancePool.GetManagedInstances"); scope.Start(); try { - var response = _usagesRestClient.ListByInstancePoolNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expandChildren, cancellationToken: cancellationToken); + var response = _managedInstancesRestClient.ListByInstancePoolNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken: cancellationToken); return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); } catch (Exception e) diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/DistributedAvailabilityGroupCreateOrUpdateOperation.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/DistributedAvailabilityGroupCreateOrUpdateOperation.cs new file mode 100644 index 000000000000..4625604e71d8 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/DistributedAvailabilityGroupCreateOrUpdateOperation.cs @@ -0,0 +1,77 @@ +// 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.Core; +using Azure.ResourceManager.Sql; + +namespace Azure.ResourceManager.Sql.Models +{ + /// Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. + public partial class DistributedAvailabilityGroupCreateOrUpdateOperation : Operation, IOperationSource + { + private readonly OperationInternals _operation; + + private readonly ArmResource _operationBase; + + /// Initializes a new instance of DistributedAvailabilityGroupCreateOrUpdateOperation for mocking. + protected DistributedAvailabilityGroupCreateOrUpdateOperation() + { + } + + internal DistributedAvailabilityGroupCreateOrUpdateOperation(ArmResource operationsBase, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response) + { + _operation = new OperationInternals(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "DistributedAvailabilityGroupCreateOrUpdateOperation"); + _operationBase = operationsBase; + } + + /// + public override string Id => _operation.Id; + + /// + public override DistributedAvailabilityGroup Value => _operation.Value; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override bool HasValue => _operation.HasValue; + + /// + public override Response GetRawResponse() => _operation.GetRawResponse(); + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + + DistributedAvailabilityGroup IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + return new DistributedAvailabilityGroup(_operationBase, DistributedAvailabilityGroupData.DeserializeDistributedAvailabilityGroupData(document.RootElement)); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + return new DistributedAvailabilityGroup(_operationBase, DistributedAvailabilityGroupData.DeserializeDistributedAvailabilityGroupData(document.RootElement)); + } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/DistributedAvailabilityGroupDeleteOperation.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/DistributedAvailabilityGroupDeleteOperation.cs new file mode 100644 index 000000000000..d7bb30f825a6 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/DistributedAvailabilityGroupDeleteOperation.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Sql.Models +{ + /// Drops a distributed availability group between Sql On-Prem and Sql Managed Instance. + public partial class DistributedAvailabilityGroupDeleteOperation : Operation + { + private readonly OperationInternals _operation; + + /// Initializes a new instance of DistributedAvailabilityGroupDeleteOperation for mocking. + protected DistributedAvailabilityGroupDeleteOperation() + { + } + + internal DistributedAvailabilityGroupDeleteOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response) + { + _operation = new OperationInternals(clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "DistributedAvailabilityGroupDeleteOperation"); + } + + /// + public override string Id => _operation.Id; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.GetRawResponse(); + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/DistributedAvailabilityGroupUpdateOperation.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/DistributedAvailabilityGroupUpdateOperation.cs new file mode 100644 index 000000000000..f8fb0cbccf52 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/DistributedAvailabilityGroupUpdateOperation.cs @@ -0,0 +1,77 @@ +// 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.Core; +using Azure.ResourceManager.Sql; + +namespace Azure.ResourceManager.Sql.Models +{ + /// Updates a distributed availability group replication mode. + public partial class DistributedAvailabilityGroupUpdateOperation : Operation, IOperationSource + { + private readonly OperationInternals _operation; + + private readonly ArmResource _operationBase; + + /// Initializes a new instance of DistributedAvailabilityGroupUpdateOperation for mocking. + protected DistributedAvailabilityGroupUpdateOperation() + { + } + + internal DistributedAvailabilityGroupUpdateOperation(ArmResource operationsBase, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response) + { + _operation = new OperationInternals(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "DistributedAvailabilityGroupUpdateOperation"); + _operationBase = operationsBase; + } + + /// + public override string Id => _operation.Id; + + /// + public override DistributedAvailabilityGroup Value => _operation.Value; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override bool HasValue => _operation.HasValue; + + /// + public override Response GetRawResponse() => _operation.GetRawResponse(); + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + + DistributedAvailabilityGroup IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + return new DistributedAvailabilityGroup(_operationBase, DistributedAvailabilityGroupData.DeserializeDistributedAvailabilityGroupData(document.RootElement)); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + return new DistributedAvailabilityGroup(_operationBase, DistributedAvailabilityGroupData.DeserializeDistributedAvailabilityGroupData(document.RootElement)); + } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/ServerTrustCertificateCreateOrUpdateOperation.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/ServerTrustCertificateCreateOrUpdateOperation.cs new file mode 100644 index 000000000000..3459ada8eee4 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/ServerTrustCertificateCreateOrUpdateOperation.cs @@ -0,0 +1,77 @@ +// 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.Core; +using Azure.ResourceManager.Sql; + +namespace Azure.ResourceManager.Sql.Models +{ + /// Uploads a server trust certificate from box to Sql Managed Instance. + public partial class ServerTrustCertificateCreateOrUpdateOperation : Operation, IOperationSource + { + private readonly OperationInternals _operation; + + private readonly ArmResource _operationBase; + + /// Initializes a new instance of ServerTrustCertificateCreateOrUpdateOperation for mocking. + protected ServerTrustCertificateCreateOrUpdateOperation() + { + } + + internal ServerTrustCertificateCreateOrUpdateOperation(ArmResource operationsBase, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response) + { + _operation = new OperationInternals(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "ServerTrustCertificateCreateOrUpdateOperation"); + _operationBase = operationsBase; + } + + /// + public override string Id => _operation.Id; + + /// + public override ServerTrustCertificate Value => _operation.Value; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override bool HasValue => _operation.HasValue; + + /// + public override Response GetRawResponse() => _operation.GetRawResponse(); + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + + ServerTrustCertificate IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + return new ServerTrustCertificate(_operationBase, ServerTrustCertificateData.DeserializeServerTrustCertificateData(document.RootElement)); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + return new ServerTrustCertificate(_operationBase, ServerTrustCertificateData.DeserializeServerTrustCertificateData(document.RootElement)); + } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/ServerTrustCertificateDeleteOperation.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/ServerTrustCertificateDeleteOperation.cs new file mode 100644 index 000000000000..56a247ea4257 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/LongRunningOperation/ServerTrustCertificateDeleteOperation.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Sql.Models +{ + /// Deletes a server trust certificate that was uploaded from box to Sql Managed Instance. + public partial class ServerTrustCertificateDeleteOperation : Operation + { + private readonly OperationInternals _operation; + + /// Initializes a new instance of ServerTrustCertificateDeleteOperation for mocking. + protected ServerTrustCertificateDeleteOperation() + { + } + + internal ServerTrustCertificateDeleteOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response) + { + _operation = new OperationInternals(clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "ServerTrustCertificateDeleteOperation"); + } + + /// + public override string Id => _operation.Id; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.GetRawResponse(); + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstance.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstance.cs index c581e8715b1e..d62f1f44b9a0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstance.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstance.cs @@ -546,6 +546,152 @@ Page NextPageFunc(string nextLink, int? pageSizeHint) return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); } + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/tdeCertificates + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: ManagedInstanceTdeCertificates_Create + /// Creates a TDE certificate for a given server. + /// The requested TDE certificate to be created or updated. + /// Waits for the completion of the long running operations. + /// The cancellation token to use. + /// is null. + public async virtual Task CreateManagedInstanceTdeCertificateAsync(TdeCertificate parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) + { + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var scope = _clientDiagnostics.CreateScope("ManagedInstance.CreateManagedInstanceTdeCertificate"); + scope.Start(); + try + { + var response = await _managedInstanceTdeCertificatesRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters, cancellationToken).ConfigureAwait(false); + var operation = new ManagedInstanceTdeCertificateCreateOperation(_clientDiagnostics, Pipeline, _managedInstanceTdeCertificatesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters).Request, response); + if (waitForCompletion) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/tdeCertificates + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: ManagedInstanceTdeCertificates_Create + /// Creates a TDE certificate for a given server. + /// The requested TDE certificate to be created or updated. + /// Waits for the completion of the long running operations. + /// The cancellation token to use. + /// is null. + public virtual ManagedInstanceTdeCertificateCreateOperation CreateManagedInstanceTdeCertificate(TdeCertificate parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) + { + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var scope = _clientDiagnostics.CreateScope("ManagedInstance.CreateManagedInstanceTdeCertificate"); + scope.Start(); + try + { + var response = _managedInstanceTdeCertificatesRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters, cancellationToken); + var operation = new ManagedInstanceTdeCertificateCreateOperation(_clientDiagnostics, Pipeline, _managedInstanceTdeCertificatesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters).Request, response); + if (waitForCompletion) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustGroups + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: ServerTrustGroups_ListByInstance + /// Gets a server trust groups by instance name. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetServerTrustGroupsAsync(CancellationToken cancellationToken = default) + { + async Task> FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ManagedInstance.GetServerTrustGroups"); + scope.Start(); + try + { + var response = await _serverTrustGroupsRestClient.ListByInstanceAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ManagedInstance.GetServerTrustGroups"); + scope.Start(); + try + { + var response = await _serverTrustGroupsRestClient.ListByInstanceNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustGroups + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: ServerTrustGroups_ListByInstance + /// Gets a server trust groups by instance name. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetServerTrustGroups(CancellationToken cancellationToken = default) + { + Page FirstPageFunc(int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ManagedInstance.GetServerTrustGroups"); + scope.Start(); + try + { + var response = _serverTrustGroupsRestClient.ListByInstance(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ManagedInstance.GetServerTrustGroups"); + scope.Start(); + try + { + var response = _serverTrustGroupsRestClient.ListByInstanceNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/topqueries /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} /// OperationId: ManagedInstances_ListByManagedInstance @@ -694,152 +840,6 @@ public virtual ManagedInstanceFailoverOperation Failover(ReplicaType? replicaTyp } } - /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/tdeCertificates - /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} - /// OperationId: ManagedInstanceTdeCertificates_Create - /// Creates a TDE certificate for a given server. - /// The requested TDE certificate to be created or updated. - /// Waits for the completion of the long running operations. - /// The cancellation token to use. - /// is null. - public async virtual Task CreateManagedInstanceTdeCertificateAsync(TdeCertificate parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) - { - if (parameters == null) - { - throw new ArgumentNullException(nameof(parameters)); - } - - using var scope = _clientDiagnostics.CreateScope("ManagedInstance.CreateManagedInstanceTdeCertificate"); - scope.Start(); - try - { - var response = await _managedInstanceTdeCertificatesRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters, cancellationToken).ConfigureAwait(false); - var operation = new ManagedInstanceTdeCertificateCreateOperation(_clientDiagnostics, Pipeline, _managedInstanceTdeCertificatesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters).Request, response); - if (waitForCompletion) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/tdeCertificates - /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} - /// OperationId: ManagedInstanceTdeCertificates_Create - /// Creates a TDE certificate for a given server. - /// The requested TDE certificate to be created or updated. - /// Waits for the completion of the long running operations. - /// The cancellation token to use. - /// is null. - public virtual ManagedInstanceTdeCertificateCreateOperation CreateManagedInstanceTdeCertificate(TdeCertificate parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) - { - if (parameters == null) - { - throw new ArgumentNullException(nameof(parameters)); - } - - using var scope = _clientDiagnostics.CreateScope("ManagedInstance.CreateManagedInstanceTdeCertificate"); - scope.Start(); - try - { - var response = _managedInstanceTdeCertificatesRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters, cancellationToken); - var operation = new ManagedInstanceTdeCertificateCreateOperation(_clientDiagnostics, Pipeline, _managedInstanceTdeCertificatesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters).Request, response); - if (waitForCompletion) - operation.WaitForCompletion(cancellationToken); - return operation; - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustGroups - /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} - /// OperationId: ServerTrustGroups_ListByInstance - /// Gets a server trust groups by instance name. - /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. - public virtual AsyncPageable GetServerTrustGroupsAsync(CancellationToken cancellationToken = default) - { - async Task> FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("ManagedInstance.GetServerTrustGroups"); - scope.Start(); - try - { - var response = await _serverTrustGroupsRestClient.ListByInstanceAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("ManagedInstance.GetServerTrustGroups"); - scope.Start(); - try - { - var response = await _serverTrustGroupsRestClient.ListByInstanceNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken).ConfigureAwait(false); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); - } - - /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustGroups - /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} - /// OperationId: ServerTrustGroups_ListByInstance - /// Gets a server trust groups by instance name. - /// The cancellation token to use. - /// A collection of that may take multiple service requests to iterate over. - public virtual Pageable GetServerTrustGroups(CancellationToken cancellationToken = default) - { - Page FirstPageFunc(int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("ManagedInstance.GetServerTrustGroups"); - scope.Start(); - try - { - var response = _serverTrustGroupsRestClient.ListByInstance(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - Page NextPageFunc(string nextLink, int? pageSizeHint) - { - using var scope = _clientDiagnostics.CreateScope("ManagedInstance.GetServerTrustGroups"); - scope.Start(); - try - { - var response = _serverTrustGroupsRestClient.ListByInstanceNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken); - return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); - } - #region ManagedDatabase /// Gets a collection of ManagedDatabases in the ManagedInstance. @@ -969,5 +969,25 @@ public virtual RestorableDroppedManagedDatabaseCollection GetRestorableDroppedMa return new RestorableDroppedManagedDatabaseCollection(this); } #endregion + + #region DistributedAvailabilityGroup + + /// Gets a collection of DistributedAvailabilityGroups in the ManagedInstance. + /// An object representing collection of DistributedAvailabilityGroups and their operations over a ManagedInstance. + public virtual DistributedAvailabilityGroupCollection GetDistributedAvailabilityGroups() + { + return new DistributedAvailabilityGroupCollection(this); + } + #endregion + + #region ServerTrustCertificate + + /// Gets a collection of ServerTrustCertificates in the ManagedInstance. + /// An object representing collection of ServerTrustCertificates and their operations over a ManagedInstance. + public virtual ServerTrustCertificateCollection GetServerTrustCertificates() + { + return new ServerTrustCertificateCollection(this); + } + #endregion } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceData.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceData.cs index 1dfa22546d99..e30c2849fe94 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceData.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ManagedInstanceData.cs @@ -66,12 +66,14 @@ public ManagedInstanceData(AzureLocation location) : base(location) /// Specifies maintenance configuration id to apply to this managed instance. /// List of private endpoint connections on a managed instance. /// Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. - /// The storage account type used to store backups for this instance. The options are LRS (LocallyRedundantStorage), ZRS (ZoneRedundantStorage) and GRS (GeoRedundantStorage). + /// The storage account type used to store backups for this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). + /// The storage account type to be used to store backups for this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). /// Whether or not the multi-az is enabled. /// The resource id of a user assigned identity to be used by default. /// A CMK URI of the key to use for encryption. /// The Azure Active Directory administrator of the server. - internal ManagedInstanceData(ResourceIdentifier id, string name, ResourceType type, IDictionary tags, AzureLocation location, ResourceIdentity identity, Models.Sku sku, ManagedInstancePropertiesProvisioningState? provisioningState, ManagedServerCreateMode? managedInstanceCreateMode, string fullyQualifiedDomainName, string administratorLogin, string administratorLoginPassword, string subnetId, string state, ManagedInstanceLicenseType? licenseType, int? vCores, int? storageSizeInGB, string collation, string dnsZone, string dnsZonePartner, bool? publicDataEndpointEnabled, string sourceManagedInstanceId, DateTimeOffset? restorePointInTime, ManagedInstanceProxyOverride? proxyOverride, string timezoneId, string instancePoolId, string maintenanceConfigurationId, IReadOnlyList privateEndpointConnections, string minimalTlsVersion, StorageAccountType? storageAccountType, bool? zoneRedundant, string primaryUserAssignedIdentityId, string keyId, ManagedInstanceExternalAdministrator administrators) : base(id, name, type, tags, location) + /// The managed instance's service principal. + internal ManagedInstanceData(ResourceIdentifier id, string name, ResourceType type, IDictionary tags, AzureLocation location, ResourceIdentity identity, Models.Sku sku, ManagedInstancePropertiesProvisioningState? provisioningState, ManagedServerCreateMode? managedInstanceCreateMode, string fullyQualifiedDomainName, string administratorLogin, string administratorLoginPassword, string subnetId, string state, ManagedInstanceLicenseType? licenseType, int? vCores, int? storageSizeInGB, string collation, string dnsZone, string dnsZonePartner, bool? publicDataEndpointEnabled, string sourceManagedInstanceId, DateTimeOffset? restorePointInTime, ManagedInstanceProxyOverride? proxyOverride, string timezoneId, string instancePoolId, string maintenanceConfigurationId, IReadOnlyList privateEndpointConnections, string minimalTlsVersion, BackupStorageRedundancy? currentBackupStorageRedundancy, BackupStorageRedundancy? requestedBackupStorageRedundancy, bool? zoneRedundant, string primaryUserAssignedIdentityId, string keyId, ManagedInstanceExternalAdministrator administrators, ServicePrincipal servicePrincipal) : base(id, name, type, tags, location) { Identity = identity; Sku = sku; @@ -97,11 +99,13 @@ internal ManagedInstanceData(ResourceIdentifier id, string name, ResourceType ty MaintenanceConfigurationId = maintenanceConfigurationId; PrivateEndpointConnections = privateEndpointConnections; MinimalTlsVersion = minimalTlsVersion; - StorageAccountType = storageAccountType; + CurrentBackupStorageRedundancy = currentBackupStorageRedundancy; + RequestedBackupStorageRedundancy = requestedBackupStorageRedundancy; ZoneRedundant = zoneRedundant; PrimaryUserAssignedIdentityId = primaryUserAssignedIdentityId; KeyId = keyId; Administrators = administrators; + ServicePrincipal = servicePrincipal; } /// The Azure Active Directory identity of the managed instance. @@ -165,8 +169,10 @@ internal ManagedInstanceData(ResourceIdentifier id, string name, ResourceType ty public IReadOnlyList PrivateEndpointConnections { get; } /// Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. public string MinimalTlsVersion { get; set; } - /// The storage account type used to store backups for this instance. The options are LRS (LocallyRedundantStorage), ZRS (ZoneRedundantStorage) and GRS (GeoRedundantStorage). - public StorageAccountType? StorageAccountType { get; set; } + /// The storage account type used to store backups for this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). + public BackupStorageRedundancy? CurrentBackupStorageRedundancy { get; } + /// The storage account type to be used to store backups for this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). + public BackupStorageRedundancy? RequestedBackupStorageRedundancy { get; set; } /// Whether or not the multi-az is enabled. public bool? ZoneRedundant { get; set; } /// The resource id of a user assigned identity to be used by default. @@ -175,5 +181,7 @@ internal ManagedInstanceData(ResourceIdentifier id, string name, ResourceType ty public string KeyId { get; set; } /// The Azure Active Directory administrator of the server. public ManagedInstanceExternalAdministrator Administrators { get; set; } + /// The managed instance's service principal. + public ServicePrincipal ServicePrincipal { get; set; } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/BackupStorageRedundancy.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/BackupStorageRedundancy.cs index f91e87ee069b..128880e8eb89 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/BackupStorageRedundancy.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/BackupStorageRedundancy.cs @@ -10,7 +10,7 @@ namespace Azure.ResourceManager.Sql.Models { - /// The storage redundancy type of the copied backup. + /// The storage account type used to store backups for this database. public readonly partial struct BackupStorageRedundancy : IEquatable { private readonly string _value; @@ -25,6 +25,7 @@ public BackupStorageRedundancy(string value) private const string GeoValue = "Geo"; private const string LocalValue = "Local"; private const string ZoneValue = "Zone"; + private const string GeoZoneValue = "GeoZone"; /// Geo. public static BackupStorageRedundancy Geo { get; } = new BackupStorageRedundancy(GeoValue); @@ -32,6 +33,8 @@ public BackupStorageRedundancy(string value) public static BackupStorageRedundancy Local { get; } = new BackupStorageRedundancy(LocalValue); /// Zone. public static BackupStorageRedundancy Zone { get; } = new BackupStorageRedundancy(ZoneValue); + /// GeoZone. + public static BackupStorageRedundancy GeoZone { get; } = new BackupStorageRedundancy(GeoZoneValue); /// Determines if two values are the same. public static bool operator ==(BackupStorageRedundancy left, BackupStorageRedundancy right) => left.Equals(right); /// Determines if two values are not the same. diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/CopyLongTermRetentionBackupOptions.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/CopyLongTermRetentionBackupOptions.cs index ee8fb9555623..ebef9f837b63 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/CopyLongTermRetentionBackupOptions.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/CopyLongTermRetentionBackupOptions.cs @@ -26,6 +26,6 @@ public CopyLongTermRetentionBackupOptions() /// The name of the database owns the copied backup. public string TargetDatabaseName { get; set; } /// The storage redundancy type of the copied backup. - public TargetBackupStorageRedundancy? TargetBackupStorageRedundancy { get; set; } + public BackupStorageRedundancy? TargetBackupStorageRedundancy { get; set; } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/CurrentBackupStorageRedundancy.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/CurrentBackupStorageRedundancy.cs deleted file mode 100644 index a4bb6a17adda..000000000000 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/CurrentBackupStorageRedundancy.cs +++ /dev/null @@ -1,54 +0,0 @@ -// 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 storage account type used to store backups for this database. - public readonly partial struct CurrentBackupStorageRedundancy : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public CurrentBackupStorageRedundancy(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string GeoValue = "Geo"; - private const string LocalValue = "Local"; - private const string ZoneValue = "Zone"; - - /// Geo. - public static CurrentBackupStorageRedundancy Geo { get; } = new CurrentBackupStorageRedundancy(GeoValue); - /// Local. - public static CurrentBackupStorageRedundancy Local { get; } = new CurrentBackupStorageRedundancy(LocalValue); - /// Zone. - public static CurrentBackupStorageRedundancy Zone { get; } = new CurrentBackupStorageRedundancy(ZoneValue); - /// Determines if two values are the same. - public static bool operator ==(CurrentBackupStorageRedundancy left, CurrentBackupStorageRedundancy right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(CurrentBackupStorageRedundancy left, CurrentBackupStorageRedundancy right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator CurrentBackupStorageRedundancy(string value) => new CurrentBackupStorageRedundancy(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is CurrentBackupStorageRedundancy other && Equals(other); - /// - public bool Equals(CurrentBackupStorageRedundancy 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/DatabaseIdentity.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseIdentity.Serialization.cs new file mode 100644 index 000000000000..a0a128bb53bc --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseIdentity.Serialization.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Sql.Models +{ + public partial class DatabaseIdentity : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"); + writer.WriteStringValue(Type.Value.ToString()); + } + if (Optional.IsCollectionDefined(UserAssignedIdentities)) + { + writer.WritePropertyName("userAssignedIdentities"); + writer.WriteStartObject(); + foreach (var item in UserAssignedIdentities) + { + writer.WritePropertyName(item.Key); + JsonSerializer.Serialize(writer, item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsCollectionDefined(DelegatedResources)) + { + writer.WritePropertyName("delegatedResources"); + writer.WriteStartObject(); + foreach (var item in DelegatedResources) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WriteEndObject(); + } + + internal static DatabaseIdentity DeserializeDatabaseIdentity(JsonElement element) + { + Optional type = default; + Optional tenantId = default; + Optional> userAssignedIdentities = default; + Optional> delegatedResources = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + type = new DatabaseIdentityType(property.Value.GetString()); + continue; + } + if (property.NameEquals("tenantId")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + tenantId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("userAssignedIdentities")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, JsonSerializer.Deserialize(property0.Value.ToString())); + } + userAssignedIdentities = dictionary; + continue; + } + if (property.NameEquals("delegatedResources")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, Delegation.DeserializeDelegation(property0.Value)); + } + delegatedResources = dictionary; + continue; + } + } + return new DatabaseIdentity(Optional.ToNullable(type), Optional.ToNullable(tenantId), Optional.ToDictionary(userAssignedIdentities), Optional.ToDictionary(delegatedResources)); + } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseIdentity.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseIdentity.cs new file mode 100644 index 000000000000..8cdc0dc06d58 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseIdentity.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.Sql.Models +{ + /// Azure Active Directory identity configuration for a resource. + public partial class DatabaseIdentity + { + /// Initializes a new instance of DatabaseIdentity. + public DatabaseIdentity() + { + UserAssignedIdentities = new ChangeTrackingDictionary(); + DelegatedResources = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of DatabaseIdentity. + /// The identity type. + /// The Azure Active Directory tenant id. + /// The resource ids of the user assigned identities to use. + /// Resources delegated to the database - Internal Use Only. + internal DatabaseIdentity(DatabaseIdentityType? type, Guid? tenantId, IDictionary userAssignedIdentities, IDictionary delegatedResources) + { + Type = type; + TenantId = tenantId; + UserAssignedIdentities = userAssignedIdentities; + DelegatedResources = delegatedResources; + } + + /// The identity type. + public DatabaseIdentityType? Type { get; set; } + /// The Azure Active Directory tenant id. + public Guid? TenantId { get; } + /// The resource ids of the user assigned identities to use. + public IDictionary UserAssignedIdentities { get; } + /// Resources delegated to the database - Internal Use Only. + public IDictionary DelegatedResources { get; } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseIdentityType.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseIdentityType.cs new file mode 100644 index 000000000000..263a17f7b722 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseIdentityType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Sql.Models +{ + /// The identity type. + public readonly partial struct DatabaseIdentityType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DatabaseIdentityType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string UserAssignedValue = "UserAssigned"; + + /// None. + public static DatabaseIdentityType None { get; } = new DatabaseIdentityType(NoneValue); + /// UserAssigned. + public static DatabaseIdentityType UserAssigned { get; } = new DatabaseIdentityType(UserAssignedValue); + /// Determines if two values are the same. + public static bool operator ==(DatabaseIdentityType left, DatabaseIdentityType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DatabaseIdentityType left, DatabaseIdentityType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DatabaseIdentityType(string value) => new DatabaseIdentityType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DatabaseIdentityType other && Equals(other); + /// + public bool Equals(DatabaseIdentityType 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/DatabaseStatus.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseStatus.cs index 0f2a12829f4c..6080fa5ff97d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseStatus.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseStatus.cs @@ -43,6 +43,9 @@ public DatabaseStatus(string value) private const string OfflineChangingDwPerformanceTiersValue = "OfflineChangingDwPerformanceTiers"; private const string OnlineChangingDwPerformanceTiersValue = "OnlineChangingDwPerformanceTiers"; private const string DisabledValue = "Disabled"; + private const string StoppingValue = "Stopping"; + private const string StoppedValue = "Stopped"; + private const string StartingValue = "Starting"; /// Online. public static DatabaseStatus Online { get; } = new DatabaseStatus(OnlineValue); @@ -86,6 +89,12 @@ public DatabaseStatus(string value) public static DatabaseStatus OnlineChangingDwPerformanceTiers { get; } = new DatabaseStatus(OnlineChangingDwPerformanceTiersValue); /// Disabled. public static DatabaseStatus Disabled { get; } = new DatabaseStatus(DisabledValue); + /// Stopping. + public static DatabaseStatus Stopping { get; } = new DatabaseStatus(StoppingValue); + /// Stopped. + public static DatabaseStatus Stopped { get; } = new DatabaseStatus(StoppedValue); + /// Starting. + public static DatabaseStatus Starting { get; } = new DatabaseStatus(StartingValue); /// Determines if two values are the same. public static bool operator ==(DatabaseStatus left, DatabaseStatus right) => left.Equals(right); /// Determines if two values are not the same. diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUpdate.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUpdate.Serialization.cs index bc9a2063e110..df305d1e650f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUpdate.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUpdate.Serialization.cs @@ -20,6 +20,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("sku"); writer.WriteObjectValue(Sku); } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"); + writer.WriteObjectValue(Identity); + } if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"); @@ -148,6 +153,16 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("isLedgerOn"); writer.WriteBooleanValue(IsLedgerOn.Value); } + if (Optional.IsDefined(FederatedClientId)) + { + writer.WritePropertyName("federatedClientId"); + writer.WriteStringValue(FederatedClientId.Value); + } + if (Optional.IsDefined(PrimaryDelegatedIdentityClientId)) + { + writer.WritePropertyName("primaryDelegatedIdentityClientId"); + writer.WriteStringValue(PrimaryDelegatedIdentityClientId.Value); + } writer.WriteEndObject(); writer.WriteEndObject(); } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUpdate.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUpdate.cs index bdcdf4481a0b..f6dc6594f98f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUpdate.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DatabaseUpdate.cs @@ -22,6 +22,8 @@ public DatabaseUpdate() /// The name and tier of the SKU. public Sku Sku { get; set; } + /// Database identity. + public DatabaseIdentity Identity { get; set; } /// Resource tags. public IDictionary Tags { get; } /// @@ -101,9 +103,9 @@ public DatabaseUpdate() /// Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled. public int? AutoPauseDelay { get; set; } /// The storage account type used to store backups for this database. - public CurrentBackupStorageRedundancy? CurrentBackupStorageRedundancy { get; } + public BackupStorageRedundancy? CurrentBackupStorageRedundancy { get; } /// The storage account type to be used to store backups for this database. - public RequestedBackupStorageRedundancy? RequestedBackupStorageRedundancy { get; set; } + public BackupStorageRedundancy? RequestedBackupStorageRedundancy { get; set; } /// Minimal capacity that database will always have allocated, if not paused. public double? MinCapacity { get; set; } /// The date when database was paused by user configuration or action(ISO8601 format). Null if the database is ready. @@ -116,5 +118,9 @@ public DatabaseUpdate() public bool? IsLedgerOn { get; set; } /// Infra encryption is enabled for this database. public bool? IsInfraEncryptionEnabled { get; } + /// The Client id used for cross tenant per database CMK scenario. + public Guid? FederatedClientId { get; set; } + /// The Primary Delegated Identity Client id used for per database CMK - for internal use only. + public Guid? PrimaryDelegatedIdentityClientId { get; set; } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/Delegation.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/Delegation.Serialization.cs new file mode 100644 index 000000000000..fbf22ed21450 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/Delegation.Serialization.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sql.Models +{ + public partial class Delegation : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(ResourceId)) + { + writer.WritePropertyName("resourceId"); + writer.WriteStringValue(ResourceId); + } + writer.WriteEndObject(); + } + + internal static Delegation DeserializeDelegation(JsonElement element) + { + Optional resourceId = default; + Optional tenantId = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceId")) + { + resourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("tenantId")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + tenantId = property.Value.GetGuid(); + continue; + } + } + return new Delegation(resourceId.Value, Optional.ToNullable(tenantId)); + } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/Delegation.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/Delegation.cs new file mode 100644 index 000000000000..f70659e50303 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/Delegation.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.Sql.Models +{ + /// Delegated Resource Properties - Internal Use Only. + public partial class Delegation + { + /// Initializes a new instance of Delegation. + public Delegation() + { + } + + /// Initializes a new instance of Delegation. + /// The resource id of the source resource - Internal Use Only. + /// AAD tenant guid of the source resource identity - Internal Use Only. + internal Delegation(string resourceId, Guid? tenantId) + { + ResourceId = resourceId; + TenantId = tenantId; + } + + /// The resource id of the source resource - Internal Use Only. + public string ResourceId { get; set; } + /// AAD tenant guid of the source resource identity - Internal Use Only. + public Guid? TenantId { get; } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DistributedAvailabilityGroupData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DistributedAvailabilityGroupData.Serialization.cs new file mode 100644 index 000000000000..35c30f8835de --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DistributedAvailabilityGroupData.Serialization.cs @@ -0,0 +1,169 @@ +// 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.Sql.Models; + +namespace Azure.ResourceManager.Sql +{ + public partial class DistributedAvailabilityGroupData : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("properties"); + writer.WriteStartObject(); + if (Optional.IsDefined(TargetDatabase)) + { + writer.WritePropertyName("targetDatabase"); + writer.WriteStringValue(TargetDatabase); + } + if (Optional.IsDefined(SourceEndpoint)) + { + writer.WritePropertyName("sourceEndpoint"); + writer.WriteStringValue(SourceEndpoint); + } + if (Optional.IsDefined(PrimaryAvailabilityGroupName)) + { + writer.WritePropertyName("primaryAvailabilityGroupName"); + writer.WriteStringValue(PrimaryAvailabilityGroupName); + } + if (Optional.IsDefined(SecondaryAvailabilityGroupName)) + { + writer.WritePropertyName("secondaryAvailabilityGroupName"); + writer.WriteStringValue(SecondaryAvailabilityGroupName); + } + if (Optional.IsDefined(ReplicationMode)) + { + writer.WritePropertyName("replicationMode"); + writer.WriteStringValue(ReplicationMode.Value.ToString()); + } + writer.WriteEndObject(); + writer.WriteEndObject(); + } + + internal static DistributedAvailabilityGroupData DeserializeDistributedAvailabilityGroupData(JsonElement element) + { + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + Optional targetDatabase = default; + Optional sourceEndpoint = default; + Optional primaryAvailabilityGroupName = default; + Optional secondaryAvailabilityGroupName = default; + Optional replicationMode = default; + Optional distributedAvailabilityGroupId = default; + Optional sourceReplicaId = default; + Optional targetReplicaId = default; + Optional linkState = default; + Optional lastHardenedLsn = 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 = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("targetDatabase")) + { + targetDatabase = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("sourceEndpoint")) + { + sourceEndpoint = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("primaryAvailabilityGroupName")) + { + primaryAvailabilityGroupName = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("secondaryAvailabilityGroupName")) + { + secondaryAvailabilityGroupName = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("replicationMode")) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + replicationMode = new ReplicationMode(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("distributedAvailabilityGroupId")) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + distributedAvailabilityGroupId = property0.Value.GetGuid(); + continue; + } + if (property0.NameEquals("sourceReplicaId")) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + sourceReplicaId = property0.Value.GetGuid(); + continue; + } + if (property0.NameEquals("targetReplicaId")) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + targetReplicaId = property0.Value.GetGuid(); + continue; + } + if (property0.NameEquals("linkState")) + { + linkState = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("lastHardenedLsn")) + { + lastHardenedLsn = property0.Value.GetString(); + continue; + } + } + continue; + } + } + return new DistributedAvailabilityGroupData(id, name, type, targetDatabase.Value, sourceEndpoint.Value, primaryAvailabilityGroupName.Value, secondaryAvailabilityGroupName.Value, Optional.ToNullable(replicationMode), Optional.ToNullable(distributedAvailabilityGroupId), Optional.ToNullable(sourceReplicaId), Optional.ToNullable(targetReplicaId), linkState.Value, lastHardenedLsn.Value); + } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DistributedAvailabilityGroupsListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DistributedAvailabilityGroupsListResult.Serialization.cs new file mode 100644 index 000000000000..855eeb4d2213 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DistributedAvailabilityGroupsListResult.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 DistributedAvailabilityGroupsListResult + { + internal static DistributedAvailabilityGroupsListResult DeserializeDistributedAvailabilityGroupsListResult(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(DistributedAvailabilityGroupData.DeserializeDistributedAvailabilityGroupData(item)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink")) + { + nextLink = property.Value.GetString(); + continue; + } + } + return new DistributedAvailabilityGroupsListResult(Optional.ToList(value), nextLink.Value); + } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DistributedAvailabilityGroupsListResult.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DistributedAvailabilityGroupsListResult.cs new file mode 100644 index 000000000000..6ffe53b29775 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/DistributedAvailabilityGroupsListResult.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 distributed availability groups in instance. + internal partial class DistributedAvailabilityGroupsListResult + { + /// Initializes a new instance of DistributedAvailabilityGroupsListResult. + internal DistributedAvailabilityGroupsListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of DistributedAvailabilityGroupsListResult. + /// Array of results. + /// Link to retrieve next page of results. + internal DistributedAvailabilityGroupsListResult(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/ManagedInstanceData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceData.Serialization.cs index b3520cf49740..3f0a455d73f6 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceData.Serialization.cs @@ -125,10 +125,10 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("minimalTlsVersion"); writer.WriteStringValue(MinimalTlsVersion); } - if (Optional.IsDefined(StorageAccountType)) + if (Optional.IsDefined(RequestedBackupStorageRedundancy)) { - writer.WritePropertyName("storageAccountType"); - writer.WriteStringValue(StorageAccountType.Value.ToString()); + writer.WritePropertyName("requestedBackupStorageRedundancy"); + writer.WriteStringValue(RequestedBackupStorageRedundancy.Value.ToString()); } if (Optional.IsDefined(ZoneRedundant)) { @@ -150,6 +150,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("administrators"); writer.WriteObjectValue(Administrators); } + if (Optional.IsDefined(ServicePrincipal)) + { + writer.WritePropertyName("servicePrincipal"); + writer.WriteObjectValue(ServicePrincipal); + } writer.WriteEndObject(); writer.WriteEndObject(); } @@ -185,11 +190,13 @@ internal static ManagedInstanceData DeserializeManagedInstanceData(JsonElement e Optional maintenanceConfigurationId = default; Optional> privateEndpointConnections = default; Optional minimalTlsVersion = default; - Optional storageAccountType = default; + Optional currentBackupStorageRedundancy = default; + Optional requestedBackupStorageRedundancy = default; Optional zoneRedundant = default; Optional primaryUserAssignedIdentityId = default; Optional keyId = default; Optional administrators = default; + Optional servicePrincipal = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("identity")) @@ -411,14 +418,24 @@ internal static ManagedInstanceData DeserializeManagedInstanceData(JsonElement e minimalTlsVersion = property0.Value.GetString(); continue; } - if (property0.NameEquals("storageAccountType")) + if (property0.NameEquals("currentBackupStorageRedundancy")) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + currentBackupStorageRedundancy = new BackupStorageRedundancy(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("requestedBackupStorageRedundancy")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } - storageAccountType = new StorageAccountType(property0.Value.GetString()); + requestedBackupStorageRedundancy = new BackupStorageRedundancy(property0.Value.GetString()); continue; } if (property0.NameEquals("zoneRedundant")) @@ -451,11 +468,21 @@ internal static ManagedInstanceData DeserializeManagedInstanceData(JsonElement e administrators = ManagedInstanceExternalAdministrator.DeserializeManagedInstanceExternalAdministrator(property0.Value); continue; } + if (property0.NameEquals("servicePrincipal")) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + servicePrincipal = ServicePrincipal.DeserializeServicePrincipal(property0.Value); + continue; + } } continue; } } - return new ManagedInstanceData(id, name, type, tags, location, identity.Value, sku.Value, Optional.ToNullable(provisioningState), Optional.ToNullable(managedInstanceCreateMode), fullyQualifiedDomainName.Value, administratorLogin.Value, administratorLoginPassword.Value, subnetId.Value, state.Value, Optional.ToNullable(licenseType), Optional.ToNullable(vCores), Optional.ToNullable(storageSizeInGB), collation.Value, dnsZone.Value, dnsZonePartner.Value, Optional.ToNullable(publicDataEndpointEnabled), sourceManagedInstanceId.Value, Optional.ToNullable(restorePointInTime), Optional.ToNullable(proxyOverride), timezoneId.Value, instancePoolId.Value, maintenanceConfigurationId.Value, Optional.ToList(privateEndpointConnections), minimalTlsVersion.Value, Optional.ToNullable(storageAccountType), Optional.ToNullable(zoneRedundant), primaryUserAssignedIdentityId.Value, keyId.Value, administrators.Value); + return new ManagedInstanceData(id, name, type, tags, location, identity.Value, sku.Value, Optional.ToNullable(provisioningState), Optional.ToNullable(managedInstanceCreateMode), fullyQualifiedDomainName.Value, administratorLogin.Value, administratorLoginPassword.Value, subnetId.Value, state.Value, Optional.ToNullable(licenseType), Optional.ToNullable(vCores), Optional.ToNullable(storageSizeInGB), collation.Value, dnsZone.Value, dnsZonePartner.Value, Optional.ToNullable(publicDataEndpointEnabled), sourceManagedInstanceId.Value, Optional.ToNullable(restorePointInTime), Optional.ToNullable(proxyOverride), timezoneId.Value, instancePoolId.Value, maintenanceConfigurationId.Value, Optional.ToList(privateEndpointConnections), minimalTlsVersion.Value, Optional.ToNullable(currentBackupStorageRedundancy), Optional.ToNullable(requestedBackupStorageRedundancy), Optional.ToNullable(zoneRedundant), primaryUserAssignedIdentityId.Value, keyId.Value, administrators.Value, servicePrincipal.Value); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePropertiesProvisioningState.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePropertiesProvisioningState.cs index 309aee81a204..4e611e194278 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePropertiesProvisioningState.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstancePropertiesProvisioningState.cs @@ -28,6 +28,15 @@ public ManagedInstancePropertiesProvisioningState(string value) private const string UnknownValue = "Unknown"; private const string SucceededValue = "Succeeded"; private const string FailedValue = "Failed"; + private const string AcceptedValue = "Accepted"; + private const string CreatedValue = "Created"; + private const string DeletedValue = "Deleted"; + private const string UnrecognizedValue = "Unrecognized"; + private const string RunningValue = "Running"; + private const string CanceledValue = "Canceled"; + private const string NotSpecifiedValue = "NotSpecified"; + private const string RegisteringValue = "Registering"; + private const string TimedOutValue = "TimedOut"; /// Creating. public static ManagedInstancePropertiesProvisioningState Creating { get; } = new ManagedInstancePropertiesProvisioningState(CreatingValue); @@ -41,6 +50,24 @@ public ManagedInstancePropertiesProvisioningState(string value) public static ManagedInstancePropertiesProvisioningState Succeeded { get; } = new ManagedInstancePropertiesProvisioningState(SucceededValue); /// Failed. public static ManagedInstancePropertiesProvisioningState Failed { get; } = new ManagedInstancePropertiesProvisioningState(FailedValue); + /// Accepted. + public static ManagedInstancePropertiesProvisioningState Accepted { get; } = new ManagedInstancePropertiesProvisioningState(AcceptedValue); + /// Created. + public static ManagedInstancePropertiesProvisioningState Created { get; } = new ManagedInstancePropertiesProvisioningState(CreatedValue); + /// Deleted. + public static ManagedInstancePropertiesProvisioningState Deleted { get; } = new ManagedInstancePropertiesProvisioningState(DeletedValue); + /// Unrecognized. + public static ManagedInstancePropertiesProvisioningState Unrecognized { get; } = new ManagedInstancePropertiesProvisioningState(UnrecognizedValue); + /// Running. + public static ManagedInstancePropertiesProvisioningState Running { get; } = new ManagedInstancePropertiesProvisioningState(RunningValue); + /// Canceled. + public static ManagedInstancePropertiesProvisioningState Canceled { get; } = new ManagedInstancePropertiesProvisioningState(CanceledValue); + /// NotSpecified. + public static ManagedInstancePropertiesProvisioningState NotSpecified { get; } = new ManagedInstancePropertiesProvisioningState(NotSpecifiedValue); + /// Registering. + public static ManagedInstancePropertiesProvisioningState Registering { get; } = new ManagedInstancePropertiesProvisioningState(RegisteringValue); + /// TimedOut. + public static ManagedInstancePropertiesProvisioningState TimedOut { get; } = new ManagedInstancePropertiesProvisioningState(TimedOutValue); /// Determines if two values are the same. public static bool operator ==(ManagedInstancePropertiesProvisioningState left, ManagedInstancePropertiesProvisioningState right) => left.Equals(right); /// Determines if two values are not the same. diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceUpdate.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceUpdate.Serialization.cs index 7d5f9728342e..4d1b3a23c7b6 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceUpdate.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceUpdate.Serialization.cs @@ -123,10 +123,10 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("minimalTlsVersion"); writer.WriteStringValue(MinimalTlsVersion); } - if (Optional.IsDefined(StorageAccountType)) + if (Optional.IsDefined(RequestedBackupStorageRedundancy)) { - writer.WritePropertyName("storageAccountType"); - writer.WriteStringValue(StorageAccountType.Value.ToString()); + writer.WritePropertyName("requestedBackupStorageRedundancy"); + writer.WriteStringValue(RequestedBackupStorageRedundancy.Value.ToString()); } if (Optional.IsDefined(ZoneRedundant)) { @@ -148,6 +148,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("administrators"); writer.WriteObjectValue(Administrators); } + if (Optional.IsDefined(ServicePrincipal)) + { + writer.WritePropertyName("servicePrincipal"); + writer.WriteObjectValue(ServicePrincipal); + } writer.WriteEndObject(); writer.WriteEndObject(); } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceUpdate.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceUpdate.cs index 0994409bc92e..c3fc088c5664 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceUpdate.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ManagedInstanceUpdate.cs @@ -84,8 +84,10 @@ public ManagedInstanceUpdate() public IReadOnlyList PrivateEndpointConnections { get; } /// Minimal TLS version. Allowed values: 'None', '1.0', '1.1', '1.2'. public string MinimalTlsVersion { get; set; } - /// The storage account type used to store backups for this instance. The options are LRS (LocallyRedundantStorage), ZRS (ZoneRedundantStorage) and GRS (GeoRedundantStorage). - public StorageAccountType? StorageAccountType { get; set; } + /// The storage account type used to store backups for this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). + public BackupStorageRedundancy? CurrentBackupStorageRedundancy { get; } + /// The storage account type to be used to store backups for this instance. The options are Local (LocallyRedundantStorage), Zone (ZoneRedundantStorage), Geo (GeoRedundantStorage) and GeoZone(GeoZoneRedundantStorage). + public BackupStorageRedundancy? RequestedBackupStorageRedundancy { get; set; } /// Whether or not the multi-az is enabled. public bool? ZoneRedundant { get; set; } /// The resource id of a user assigned identity to be used by default. @@ -94,5 +96,7 @@ public ManagedInstanceUpdate() public string KeyId { get; set; } /// The Azure Active Directory administrator of the server. public ManagedInstanceExternalAdministrator Administrators { get; set; } + /// The managed instance's service principal. + public ServicePrincipal ServicePrincipal { get; set; } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OperationsHealth.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OperationsHealth.cs deleted file mode 100644 index 3717a9d964aa..000000000000 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OperationsHealth.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using Azure.Core; -using Azure.ResourceManager.Models; - -namespace Azure.ResourceManager.Sql.Models -{ - /// Operations health status in a location. - public partial class OperationsHealth : Resource - { - /// Initializes a new instance of OperationsHealth. - public OperationsHealth() - { - } - - /// Initializes a new instance of OperationsHealth. - /// The id. - /// The name. - /// The type. - /// Operation name for the service. - /// Operation health status of the service. - /// Health status description. - internal OperationsHealth(ResourceIdentifier id, string name, ResourceType type, string namePropertiesName, string health, string description) : base(id, name, type) - { - NamePropertiesName = namePropertiesName; - Health = health; - Description = description; - } - - /// Operation name for the service. - public string NamePropertiesName { get; } - /// Operation health status of the service. - public string Health { get; } - /// Health status description. - public string Description { get; } - } -} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OperationsHealthListResult.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OperationsHealthListResult.cs deleted file mode 100644 index 5c2dd6138dcd..000000000000 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OperationsHealthListResult.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System.Collections.Generic; -using Azure.Core; - -namespace Azure.ResourceManager.Sql.Models -{ - /// A list of service health statuses in a location. - internal partial class OperationsHealthListResult - { - /// Initializes a new instance of OperationsHealthListResult. - internal OperationsHealthListResult() - { - Value = new ChangeTrackingList(); - } - - /// Initializes a new instance of OperationsHealthListResult. - /// Array of results. - /// Link to retrieve next page of results. - internal OperationsHealthListResult(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/ReplicationMode.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ReplicationMode.cs new file mode 100644 index 000000000000..56bbcbea94da --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ReplicationMode.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Sql.Models +{ + /// The replication mode of a distributed availability group. Parameter will be ignored during link creation. + public readonly partial struct ReplicationMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ReplicationMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AsyncValue = "Async"; + private const string SyncValue = "Sync"; + + /// Async. + public static ReplicationMode Async { get; } = new ReplicationMode(AsyncValue); + /// Sync. + public static ReplicationMode Sync { get; } = new ReplicationMode(SyncValue); + /// Determines if two values are the same. + public static bool operator ==(ReplicationMode left, ReplicationMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ReplicationMode left, ReplicationMode right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ReplicationMode(string value) => new ReplicationMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ReplicationMode other && Equals(other); + /// + public bool Equals(ReplicationMode 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/RequestedBackupStorageRedundancy.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RequestedBackupStorageRedundancy.cs deleted file mode 100644 index c607d93cbc8d..000000000000 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RequestedBackupStorageRedundancy.cs +++ /dev/null @@ -1,54 +0,0 @@ -// 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 storage redundancy type of the copied backup. - public readonly partial struct RequestedBackupStorageRedundancy : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public RequestedBackupStorageRedundancy(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string GeoValue = "Geo"; - private const string LocalValue = "Local"; - private const string ZoneValue = "Zone"; - - /// Geo. - public static RequestedBackupStorageRedundancy Geo { get; } = new RequestedBackupStorageRedundancy(GeoValue); - /// Local. - public static RequestedBackupStorageRedundancy Local { get; } = new RequestedBackupStorageRedundancy(LocalValue); - /// Zone. - public static RequestedBackupStorageRedundancy Zone { get; } = new RequestedBackupStorageRedundancy(ZoneValue); - /// Determines if two values are the same. - public static bool operator ==(RequestedBackupStorageRedundancy left, RequestedBackupStorageRedundancy right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(RequestedBackupStorageRedundancy left, RequestedBackupStorageRedundancy right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator RequestedBackupStorageRedundancy(string value) => new RequestedBackupStorageRedundancy(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RequestedBackupStorageRedundancy other && Equals(other); - /// - public bool Equals(RequestedBackupStorageRedundancy 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/RestorableDroppedDatabaseData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorableDroppedDatabaseData.Serialization.cs index 7002939701bc..b7de03bef24d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorableDroppedDatabaseData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorableDroppedDatabaseData.Serialization.cs @@ -55,11 +55,10 @@ internal static RestorableDroppedDatabaseData DeserializeRestorableDroppedDataba ResourceType type = default; Optional databaseName = default; Optional maxSizeBytes = default; - Optional elasticPoolId = default; Optional creationDate = default; Optional deletionDate = default; Optional earliestRestoreDate = default; - Optional backupStorageRedundancy = default; + Optional backupStorageRedundancy = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sku")) @@ -131,11 +130,6 @@ internal static RestorableDroppedDatabaseData DeserializeRestorableDroppedDataba maxSizeBytes = property0.Value.GetInt64(); continue; } - if (property0.NameEquals("elasticPoolId")) - { - elasticPoolId = property0.Value.GetString(); - continue; - } if (property0.NameEquals("creationDate")) { if (property0.Value.ValueKind == JsonValueKind.Null) @@ -173,14 +167,14 @@ internal static RestorableDroppedDatabaseData DeserializeRestorableDroppedDataba property0.ThrowNonNullablePropertyIsNull(); continue; } - backupStorageRedundancy = new RestorableDroppedDatabasePropertiesBackupStorageRedundancy(property0.Value.GetString()); + backupStorageRedundancy = new BackupStorageRedundancy(property0.Value.GetString()); continue; } } continue; } } - return new RestorableDroppedDatabaseData(id, name, type, sku.Value, location.Value, Optional.ToDictionary(tags), databaseName.Value, Optional.ToNullable(maxSizeBytes), elasticPoolId.Value, Optional.ToNullable(creationDate), Optional.ToNullable(deletionDate), Optional.ToNullable(earliestRestoreDate), Optional.ToNullable(backupStorageRedundancy)); + return new RestorableDroppedDatabaseData(id, name, type, sku.Value, location.Value, Optional.ToDictionary(tags), databaseName.Value, Optional.ToNullable(maxSizeBytes), Optional.ToNullable(creationDate), Optional.ToNullable(deletionDate), Optional.ToNullable(earliestRestoreDate), Optional.ToNullable(backupStorageRedundancy)); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorableDroppedDatabasePropertiesBackupStorageRedundancy.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorableDroppedDatabasePropertiesBackupStorageRedundancy.cs deleted file mode 100644 index 58e9e1443239..000000000000 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/RestorableDroppedDatabasePropertiesBackupStorageRedundancy.cs +++ /dev/null @@ -1,54 +0,0 @@ -// 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 storage account type used to store backups for this database. - public readonly partial struct RestorableDroppedDatabasePropertiesBackupStorageRedundancy : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public RestorableDroppedDatabasePropertiesBackupStorageRedundancy(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string GeoValue = "Geo"; - private const string LocalValue = "Local"; - private const string ZoneValue = "Zone"; - - /// Geo. - public static RestorableDroppedDatabasePropertiesBackupStorageRedundancy Geo { get; } = new RestorableDroppedDatabasePropertiesBackupStorageRedundancy(GeoValue); - /// Local. - public static RestorableDroppedDatabasePropertiesBackupStorageRedundancy Local { get; } = new RestorableDroppedDatabasePropertiesBackupStorageRedundancy(LocalValue); - /// Zone. - public static RestorableDroppedDatabasePropertiesBackupStorageRedundancy Zone { get; } = new RestorableDroppedDatabasePropertiesBackupStorageRedundancy(ZoneValue); - /// Determines if two values are the same. - public static bool operator ==(RestorableDroppedDatabasePropertiesBackupStorageRedundancy left, RestorableDroppedDatabasePropertiesBackupStorageRedundancy right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(RestorableDroppedDatabasePropertiesBackupStorageRedundancy left, RestorableDroppedDatabasePropertiesBackupStorageRedundancy right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator RestorableDroppedDatabasePropertiesBackupStorageRedundancy(string value) => new RestorableDroppedDatabasePropertiesBackupStorageRedundancy(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RestorableDroppedDatabasePropertiesBackupStorageRedundancy other && Equals(other); - /// - public bool Equals(RestorableDroppedDatabasePropertiesBackupStorageRedundancy 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/OperationsHealth.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustCertificateData.Serialization.cs similarity index 64% rename from sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OperationsHealth.Serialization.cs rename to sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustCertificateData.Serialization.cs index 31a73b2c5c59..b576f399f230 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OperationsHealth.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustCertificateData.Serialization.cs @@ -8,27 +8,32 @@ using System.Text.Json; using Azure.Core; -namespace Azure.ResourceManager.Sql.Models +namespace Azure.ResourceManager.Sql { - public partial class OperationsHealth : IUtf8JsonSerializable + public partial class ServerTrustCertificateData : IUtf8JsonSerializable { void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("properties"); writer.WriteStartObject(); + if (Optional.IsDefined(PublicBlob)) + { + writer.WritePropertyName("publicBlob"); + writer.WriteStringValue(PublicBlob); + } writer.WriteEndObject(); writer.WriteEndObject(); } - internal static OperationsHealth DeserializeOperationsHealth(JsonElement element) + internal static ServerTrustCertificateData DeserializeServerTrustCertificateData(JsonElement element) { ResourceIdentifier id = default; string name = default; ResourceType type = default; - Optional name0 = default; - Optional health = default; - Optional description = default; + Optional publicBlob = default; + Optional thumbprint = default; + Optional certificateName = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) @@ -55,26 +60,26 @@ internal static OperationsHealth DeserializeOperationsHealth(JsonElement element } foreach (var property0 in property.Value.EnumerateObject()) { - if (property0.NameEquals("name")) + if (property0.NameEquals("publicBlob")) { - name0 = property0.Value.GetString(); + publicBlob = property0.Value.GetString(); continue; } - if (property0.NameEquals("health")) + if (property0.NameEquals("thumbprint")) { - health = property0.Value.GetString(); + thumbprint = property0.Value.GetString(); continue; } - if (property0.NameEquals("description")) + if (property0.NameEquals("certificateName")) { - description = property0.Value.GetString(); + certificateName = property0.Value.GetString(); continue; } } continue; } } - return new OperationsHealth(id, name, type, name0.Value, health.Value, description.Value); + return new ServerTrustCertificateData(id, name, type, publicBlob.Value, thumbprint.Value, certificateName.Value); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OperationsHealthListResult.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustCertificatesListResult.Serialization.cs similarity index 64% rename from sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OperationsHealthListResult.Serialization.cs rename to sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustCertificatesListResult.Serialization.cs index e3c818cd1a17..14cfd650be47 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/OperationsHealthListResult.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustCertificatesListResult.Serialization.cs @@ -8,14 +8,15 @@ using System.Collections.Generic; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.Sql; namespace Azure.ResourceManager.Sql.Models { - internal partial class OperationsHealthListResult + internal partial class ServerTrustCertificatesListResult { - internal static OperationsHealthListResult DeserializeOperationsHealthListResult(JsonElement element) + internal static ServerTrustCertificatesListResult DeserializeServerTrustCertificatesListResult(JsonElement element) { - Optional> value = default; + Optional> value = default; Optional nextLink = default; foreach (var property in element.EnumerateObject()) { @@ -26,10 +27,10 @@ internal static OperationsHealthListResult DeserializeOperationsHealthListResult property.ThrowNonNullablePropertyIsNull(); continue; } - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(OperationsHealth.DeserializeOperationsHealth(item)); + array.Add(ServerTrustCertificateData.DeserializeServerTrustCertificateData(item)); } value = array; continue; @@ -40,7 +41,7 @@ internal static OperationsHealthListResult DeserializeOperationsHealthListResult continue; } } - return new OperationsHealthListResult(Optional.ToList(value), nextLink.Value); + return new ServerTrustCertificatesListResult(Optional.ToList(value), nextLink.Value); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustCertificatesListResult.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustCertificatesListResult.cs new file mode 100644 index 000000000000..9429bde62587 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServerTrustCertificatesListResult.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 trust certificates which are used for secure communication between SQL On-Prem instance and the given Sql Managed Instance. + internal partial class ServerTrustCertificatesListResult + { + /// Initializes a new instance of ServerTrustCertificatesListResult. + internal ServerTrustCertificatesListResult() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of ServerTrustCertificatesListResult. + /// Array of results. + /// Link to retrieve next page of results. + internal ServerTrustCertificatesListResult(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/ServicePrincipal.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServicePrincipal.Serialization.cs new file mode 100644 index 000000000000..cb50a10bd634 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServicePrincipal.Serialization.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Sql.Models +{ + public partial class ServicePrincipal : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"); + writer.WriteStringValue(Type.Value.ToString()); + } + writer.WriteEndObject(); + } + + internal static ServicePrincipal DeserializeServicePrincipal(JsonElement element) + { + Optional principalId = default; + Optional clientId = default; + Optional tenantId = default; + Optional type = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("principalId")) + { + principalId = property.Value.GetString(); + continue; + } + if (property.NameEquals("clientId")) + { + clientId = property.Value.GetString(); + continue; + } + if (property.NameEquals("tenantId")) + { + tenantId = property.Value.GetString(); + continue; + } + if (property.NameEquals("type")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + type = new ServicePrincipalType(property.Value.GetString()); + continue; + } + } + return new ServicePrincipal(principalId.Value, clientId.Value, tenantId.Value, Optional.ToNullable(type)); + } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServicePrincipal.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServicePrincipal.cs new file mode 100644 index 000000000000..b6aa1ff53a7f --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServicePrincipal.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.Sql.Models +{ + /// The managed instance's service principal configuration for a resource. + public partial class ServicePrincipal + { + /// Initializes a new instance of ServicePrincipal. + public ServicePrincipal() + { + } + + /// Initializes a new instance of ServicePrincipal. + /// The Azure Active Directory application object id. + /// The Azure Active Directory application client id. + /// The Azure Active Directory tenant id. + /// Service principal type. + internal ServicePrincipal(string principalId, string clientId, string tenantId, ServicePrincipalType? type) + { + PrincipalId = principalId; + ClientId = clientId; + TenantId = tenantId; + Type = type; + } + + /// The Azure Active Directory application object id. + public string PrincipalId { get; } + /// The Azure Active Directory application client id. + public string ClientId { get; } + /// The Azure Active Directory tenant id. + public string TenantId { get; } + /// Service principal type. + public ServicePrincipalType? Type { get; set; } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServicePrincipalType.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServicePrincipalType.cs new file mode 100644 index 000000000000..e1ddae478065 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/ServicePrincipalType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Sql.Models +{ + /// Service principal type. + public readonly partial struct ServicePrincipalType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ServicePrincipalType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string SystemAssignedValue = "SystemAssigned"; + + /// None. + public static ServicePrincipalType None { get; } = new ServicePrincipalType(NoneValue); + /// SystemAssigned. + public static ServicePrincipalType SystemAssigned { get; } = new ServicePrincipalType(SystemAssignedValue); + /// Determines if two values are the same. + public static bool operator ==(ServicePrincipalType left, ServicePrincipalType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ServicePrincipalType left, ServicePrincipalType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ServicePrincipalType(string value) => new ServicePrincipalType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ServicePrincipalType other && Equals(other); + /// + public bool Equals(ServicePrincipalType 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/SqlDatabaseData.Serialization.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabaseData.Serialization.cs index b0d3bc573b8f..3d17eb423ab5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabaseData.Serialization.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/SqlDatabaseData.Serialization.cs @@ -23,6 +23,11 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("sku"); writer.WriteObjectValue(Sku); } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"); + writer.WriteObjectValue(Identity); + } writer.WritePropertyName("tags"); writer.WriteStartObject(); foreach (var item in Tags) @@ -150,6 +155,16 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("isLedgerOn"); writer.WriteBooleanValue(IsLedgerOn.Value); } + if (Optional.IsDefined(FederatedClientId)) + { + writer.WritePropertyName("federatedClientId"); + writer.WriteStringValue(FederatedClientId.Value); + } + if (Optional.IsDefined(PrimaryDelegatedIdentityClientId)) + { + writer.WritePropertyName("primaryDelegatedIdentityClientId"); + writer.WriteStringValue(PrimaryDelegatedIdentityClientId.Value); + } writer.WriteEndObject(); writer.WriteEndObject(); } @@ -159,6 +174,7 @@ internal static SqlDatabaseData DeserializeSqlDatabaseData(JsonElement element) Optional sku = default; Optional kind = default; Optional managedBy = default; + Optional identity = default; IDictionary tags = default; AzureLocation location = default; ResourceIdentifier id = default; @@ -193,14 +209,16 @@ internal static SqlDatabaseData DeserializeSqlDatabaseData(JsonElement element) Optional secondaryType = default; Optional currentSku = default; Optional autoPauseDelay = default; - Optional currentBackupStorageRedundancy = default; - Optional requestedBackupStorageRedundancy = default; + Optional currentBackupStorageRedundancy = default; + Optional requestedBackupStorageRedundancy = default; Optional minCapacity = default; Optional pausedDate = default; Optional resumedDate = default; Optional maintenanceConfigurationId = default; Optional isLedgerOn = default; Optional isInfraEncryptionEnabled = default; + Optional federatedClientId = default; + Optional primaryDelegatedIdentityClientId = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sku")) @@ -223,6 +241,16 @@ internal static SqlDatabaseData DeserializeSqlDatabaseData(JsonElement element) managedBy = property.Value.GetString(); continue; } + if (property.NameEquals("identity")) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + identity = DatabaseIdentity.DeserializeDatabaseIdentity(property.Value); + continue; + } if (property.NameEquals("tags")) { Dictionary dictionary = new Dictionary(); @@ -504,7 +532,7 @@ internal static SqlDatabaseData DeserializeSqlDatabaseData(JsonElement element) property0.ThrowNonNullablePropertyIsNull(); continue; } - currentBackupStorageRedundancy = new CurrentBackupStorageRedundancy(property0.Value.GetString()); + currentBackupStorageRedundancy = new BackupStorageRedundancy(property0.Value.GetString()); continue; } if (property0.NameEquals("requestedBackupStorageRedundancy")) @@ -514,7 +542,7 @@ internal static SqlDatabaseData DeserializeSqlDatabaseData(JsonElement element) property0.ThrowNonNullablePropertyIsNull(); continue; } - requestedBackupStorageRedundancy = new RequestedBackupStorageRedundancy(property0.Value.GetString()); + requestedBackupStorageRedundancy = new BackupStorageRedundancy(property0.Value.GetString()); continue; } if (property0.NameEquals("minCapacity")) @@ -572,11 +600,31 @@ internal static SqlDatabaseData DeserializeSqlDatabaseData(JsonElement element) isInfraEncryptionEnabled = property0.Value.GetBoolean(); continue; } + if (property0.NameEquals("federatedClientId")) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + federatedClientId = property0.Value.GetGuid(); + continue; + } + if (property0.NameEquals("primaryDelegatedIdentityClientId")) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + property0.ThrowNonNullablePropertyIsNull(); + continue; + } + primaryDelegatedIdentityClientId = property0.Value.GetGuid(); + continue; + } } continue; } } - return new SqlDatabaseData(id, name, type, tags, location, sku.Value, kind.Value, managedBy.Value, Optional.ToNullable(createMode), collation.Value, Optional.ToNullable(maxSizeBytes), Optional.ToNullable(sampleName), elasticPoolId.Value, sourceDatabaseId.Value, Optional.ToNullable(status), Optional.ToNullable(databaseId), Optional.ToNullable(creationDate), currentServiceObjectiveName.Value, requestedServiceObjectiveName.Value, defaultSecondaryLocation.Value, failoverGroupId.Value, Optional.ToNullable(restorePointInTime), Optional.ToNullable(sourceDatabaseDeletionDate), recoveryServicesRecoveryPointId.Value, longTermRetentionBackupResourceId.Value, recoverableDatabaseId.Value, restorableDroppedDatabaseId.Value, Optional.ToNullable(catalogCollation), Optional.ToNullable(zoneRedundant), Optional.ToNullable(licenseType), Optional.ToNullable(maxLogSizeBytes), Optional.ToNullable(earliestRestoreDate), Optional.ToNullable(readScale), Optional.ToNullable(highAvailabilityReplicaCount), Optional.ToNullable(secondaryType), currentSku.Value, Optional.ToNullable(autoPauseDelay), Optional.ToNullable(currentBackupStorageRedundancy), Optional.ToNullable(requestedBackupStorageRedundancy), Optional.ToNullable(minCapacity), Optional.ToNullable(pausedDate), Optional.ToNullable(resumedDate), maintenanceConfigurationId.Value, Optional.ToNullable(isLedgerOn), Optional.ToNullable(isInfraEncryptionEnabled)); + return new SqlDatabaseData(id, name, type, tags, location, sku.Value, kind.Value, managedBy.Value, identity.Value, Optional.ToNullable(createMode), collation.Value, Optional.ToNullable(maxSizeBytes), Optional.ToNullable(sampleName), elasticPoolId.Value, sourceDatabaseId.Value, Optional.ToNullable(status), Optional.ToNullable(databaseId), Optional.ToNullable(creationDate), currentServiceObjectiveName.Value, requestedServiceObjectiveName.Value, defaultSecondaryLocation.Value, failoverGroupId.Value, Optional.ToNullable(restorePointInTime), Optional.ToNullable(sourceDatabaseDeletionDate), recoveryServicesRecoveryPointId.Value, longTermRetentionBackupResourceId.Value, recoverableDatabaseId.Value, restorableDroppedDatabaseId.Value, Optional.ToNullable(catalogCollation), Optional.ToNullable(zoneRedundant), Optional.ToNullable(licenseType), Optional.ToNullable(maxLogSizeBytes), Optional.ToNullable(earliestRestoreDate), Optional.ToNullable(readScale), Optional.ToNullable(highAvailabilityReplicaCount), Optional.ToNullable(secondaryType), currentSku.Value, Optional.ToNullable(autoPauseDelay), Optional.ToNullable(currentBackupStorageRedundancy), Optional.ToNullable(requestedBackupStorageRedundancy), Optional.ToNullable(minCapacity), Optional.ToNullable(pausedDate), Optional.ToNullable(resumedDate), maintenanceConfigurationId.Value, Optional.ToNullable(isLedgerOn), Optional.ToNullable(isInfraEncryptionEnabled), Optional.ToNullable(federatedClientId), Optional.ToNullable(primaryDelegatedIdentityClientId)); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/StorageAccountType.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/StorageAccountType.cs deleted file mode 100644 index 3228d0238f9f..000000000000 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/StorageAccountType.cs +++ /dev/null @@ -1,54 +0,0 @@ -// 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 storage account type used to store backups for this instance. The options are LRS (LocallyRedundantStorage), ZRS (ZoneRedundantStorage) and GRS (GeoRedundantStorage). - public readonly partial struct StorageAccountType : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public StorageAccountType(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string GRSValue = "GRS"; - private const string LRSValue = "LRS"; - private const string ZRSValue = "ZRS"; - - /// GRS. - public static StorageAccountType GRS { get; } = new StorageAccountType(GRSValue); - /// LRS. - public static StorageAccountType LRS { get; } = new StorageAccountType(LRSValue); - /// ZRS. - public static StorageAccountType ZRS { get; } = new StorageAccountType(ZRSValue); - /// Determines if two values are the same. - public static bool operator ==(StorageAccountType left, StorageAccountType right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(StorageAccountType left, StorageAccountType right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator StorageAccountType(string value) => new StorageAccountType(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is StorageAccountType other && Equals(other); - /// - public bool Equals(StorageAccountType 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/TargetBackupStorageRedundancy.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TargetBackupStorageRedundancy.cs deleted file mode 100644 index 6dd57e682089..000000000000 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/TargetBackupStorageRedundancy.cs +++ /dev/null @@ -1,54 +0,0 @@ -// 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 storage redundancy type of the copied backup. - public readonly partial struct TargetBackupStorageRedundancy : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public TargetBackupStorageRedundancy(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string GeoValue = "Geo"; - private const string LocalValue = "Local"; - private const string ZoneValue = "Zone"; - - /// Geo. - public static TargetBackupStorageRedundancy Geo { get; } = new TargetBackupStorageRedundancy(GeoValue); - /// Local. - public static TargetBackupStorageRedundancy Local { get; } = new TargetBackupStorageRedundancy(LocalValue); - /// Zone. - public static TargetBackupStorageRedundancy Zone { get; } = new TargetBackupStorageRedundancy(ZoneValue); - /// Determines if two values are the same. - public static bool operator ==(TargetBackupStorageRedundancy left, TargetBackupStorageRedundancy right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(TargetBackupStorageRedundancy left, TargetBackupStorageRedundancy right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator TargetBackupStorageRedundancy(string value) => new TargetBackupStorageRedundancy(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is TargetBackupStorageRedundancy other && Equals(other); - /// - public bool Equals(TargetBackupStorageRedundancy 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/UpdateLongTermRetentionBackupOptions.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/UpdateLongTermRetentionBackupOptions.cs index 6acad900ebfe..06593a8d5093 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/UpdateLongTermRetentionBackupOptions.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/Models/UpdateLongTermRetentionBackupOptions.cs @@ -16,6 +16,6 @@ public UpdateLongTermRetentionBackupOptions() } /// The storage redundancy type of the copied backup. - public RequestedBackupStorageRedundancy? RequestedBackupStorageRedundancy { get; set; } + public BackupStorageRedundancy? RequestedBackupStorageRedundancy { get; set; } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/DatabasesRestOperations.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/DatabasesRestOperations.cs index 6a2cf2f8dbe2..1bfbea442476 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/DatabasesRestOperations.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/DatabasesRestOperations.cs @@ -280,7 +280,7 @@ internal HttpMessage CreateListByServerRequest(string subscriptionId, string res { uri.AppendQuery("$skipToken", skipToken, true); } - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -378,7 +378,7 @@ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGrou uri.AppendPath(serverName, true); uri.AppendPath("/databases/", false); uri.AppendPath(databaseName, true); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -488,7 +488,7 @@ internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string r uri.AppendPath(serverName, true); uri.AppendPath("/databases/", false); uri.AppendPath(databaseName, true); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); @@ -602,7 +602,7 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath(serverName, true); uri.AppendPath("/databases/", false); uri.AppendPath(databaseName, true); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; message.SetProperty("UserAgentOverride", _userAgent); return message; @@ -701,7 +701,7 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG uri.AppendPath(serverName, true); uri.AppendPath("/databases/", false); uri.AppendPath(databaseName, true); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); @@ -814,7 +814,7 @@ internal HttpMessage CreateListByElasticPoolRequest(string subscriptionId, strin uri.AppendPath("/elasticPools/", false); uri.AppendPath(elasticPoolName, true); uri.AppendPath("/databases", false); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -925,7 +925,7 @@ internal HttpMessage CreateFailoverRequest(string subscriptionId, string resourc { uri.AppendQuery("replicaType", replicaType.Value.ToString(), true); } - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; message.SetProperty("UserAgentOverride", _userAgent); return message; @@ -1023,7 +1023,7 @@ internal HttpMessage CreateListInaccessibleByServerRequest(string subscriptionId uri.AppendPath("/providers/Microsoft.Sql/servers/", false); uri.AppendPath(serverName, true); uri.AppendPath("/inaccessibleDatabases", false); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -1120,7 +1120,7 @@ internal HttpMessage CreatePauseRequest(string subscriptionId, string resourceGr uri.AppendPath("/databases/", false); uri.AppendPath(databaseName, true); uri.AppendPath("/pause", false); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -1219,7 +1219,7 @@ internal HttpMessage CreateResumeRequest(string subscriptionId, string resourceG uri.AppendPath("/databases/", false); uri.AppendPath(databaseName, true); uri.AppendPath("/resume", false); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -1318,7 +1318,7 @@ internal HttpMessage CreateUpgradeDataWarehouseRequest(string subscriptionId, st uri.AppendPath("/databases/", false); uri.AppendPath(databaseName, true); uri.AppendPath("/upgradeDataWarehouse", false); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; message.SetProperty("UserAgentOverride", _userAgent); return message; @@ -1416,7 +1416,7 @@ internal HttpMessage CreateRenameRequest(string subscriptionId, string resourceG uri.AppendPath("/databases/", false); uri.AppendPath(databaseName, true); uri.AppendPath("/move", false); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); @@ -1526,7 +1526,7 @@ internal HttpMessage CreateImportRequest(string subscriptionId, string resourceG uri.AppendPath("/databases/", false); uri.AppendPath(databaseName, true); uri.AppendPath("/import", false); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); @@ -1639,7 +1639,7 @@ internal HttpMessage CreateExportRequest(string subscriptionId, string resourceG uri.AppendPath("/databases/", false); uri.AppendPath(databaseName, true); uri.AppendPath("/export", false); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/DistributedAvailabilityGroupsRestOperations.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/DistributedAvailabilityGroupsRestOperations.cs new file mode 100644 index 000000000000..732397967adb --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/DistributedAvailabilityGroupsRestOperations.cs @@ -0,0 +1,668 @@ +// 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.Core; +using Azure.ResourceManager.Sql.Models; + +namespace Azure.ResourceManager.Sql +{ + internal partial class DistributedAvailabilityGroupsRestOperations + { + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + private readonly string _userAgent; + + /// Initializes a new instance of DistributedAvailabilityGroupsRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The client options used to construct the current client. + /// server parameter. + public DistributedAvailabilityGroupsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, ClientOptions options, Uri endpoint = null) + { + this.endpoint = endpoint ?? new Uri("https://management.azure.com"); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _userAgent = HttpMessageUtilities.GetUserAgentName(this, options); + } + + internal HttpMessage CreateListByInstanceRequest(string subscriptionId, string resourceGroupName, string managedInstanceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Sql/managedInstances/", false); + uri.AppendPath(managedInstanceName, true); + uri.AppendPath("/distributedAvailabilityGroups", false); + uri.AppendQuery("api-version", "2021-05-01-preview", true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + message.SetProperty("UserAgentOverride", _userAgent); + return message; + } + + /// Gets a list of a distributed availability groups in instance. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The cancellation token to use. + /// , , or is null. + public async Task> ListByInstanceAsync(string subscriptionId, string resourceGroupName, string managedInstanceName, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + + using var message = CreateListByInstanceRequest(subscriptionId, resourceGroupName, managedInstanceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DistributedAvailabilityGroupsListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DistributedAvailabilityGroupsListResult.DeserializeDistributedAvailabilityGroupsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of a distributed availability groups in instance. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The cancellation token to use. + /// , , or is null. + public Response ListByInstance(string subscriptionId, string resourceGroupName, string managedInstanceName, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + + using var message = CreateListByInstanceRequest(subscriptionId, resourceGroupName, managedInstanceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DistributedAvailabilityGroupsListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DistributedAvailabilityGroupsListResult.DeserializeDistributedAvailabilityGroupsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string managedInstanceName, string distributedAvailabilityGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Sql/managedInstances/", false); + uri.AppendPath(managedInstanceName, true); + uri.AppendPath("/distributedAvailabilityGroups/", false); + uri.AppendPath(distributedAvailabilityGroupName, true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + message.SetProperty("UserAgentOverride", _userAgent); + return message; + } + + /// Gets a distributed availability group info. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The distributed availability group name. + /// The cancellation token to use. + /// , , , or is null. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string managedInstanceName, string distributedAvailabilityGroupName, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, managedInstanceName, distributedAvailabilityGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DistributedAvailabilityGroupData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DistributedAvailabilityGroupData.DeserializeDistributedAvailabilityGroupData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DistributedAvailabilityGroupData)null, message.Response); + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a distributed availability group info. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The distributed availability group name. + /// The cancellation token to use. + /// , , , or is null. + public Response Get(string subscriptionId, string resourceGroupName, string managedInstanceName, string distributedAvailabilityGroupName, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, managedInstanceName, distributedAvailabilityGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DistributedAvailabilityGroupData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DistributedAvailabilityGroupData.DeserializeDistributedAvailabilityGroupData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((DistributedAvailabilityGroupData)null, message.Response); + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string managedInstanceName, string distributedAvailabilityGroupName, DistributedAvailabilityGroupData parameters) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Sql/managedInstances/", false); + uri.AppendPath(managedInstanceName, true); + uri.AppendPath("/distributedAvailabilityGroups/", false); + uri.AppendPath(distributedAvailabilityGroupName, true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(parameters); + request.Content = content; + message.SetProperty("UserAgentOverride", _userAgent); + return message; + } + + /// Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The distributed availability group name. + /// The distributed availability group info. + /// The cancellation token to use. + /// , , , , or is null. + public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string managedInstanceName, string distributedAvailabilityGroupName, DistributedAvailabilityGroupData parameters, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, managedInstanceName, distributedAvailabilityGroupName, parameters); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + case 202: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Creates a distributed availability group between Sql On-Prem and Sql Managed Instance. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The distributed availability group name. + /// The distributed availability group info. + /// The cancellation token to use. + /// , , , , or is null. + public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string managedInstanceName, string distributedAvailabilityGroupName, DistributedAvailabilityGroupData parameters, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, managedInstanceName, distributedAvailabilityGroupName, parameters); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + case 202: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string managedInstanceName, string distributedAvailabilityGroupName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Sql/managedInstances/", false); + uri.AppendPath(managedInstanceName, true); + uri.AppendPath("/distributedAvailabilityGroups/", false); + uri.AppendPath(distributedAvailabilityGroupName, true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); + request.Uri = uri; + message.SetProperty("UserAgentOverride", _userAgent); + return message; + } + + /// Drops a distributed availability group between Sql On-Prem and Sql Managed Instance. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The distributed availability group name. + /// The cancellation token to use. + /// , , , or is null. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string managedInstanceName, string distributedAvailabilityGroupName, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, managedInstanceName, distributedAvailabilityGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Drops a distributed availability group between Sql On-Prem and Sql Managed Instance. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The distributed availability group name. + /// The cancellation token to use. + /// , , , or is null. + public Response Delete(string subscriptionId, string resourceGroupName, string managedInstanceName, string distributedAvailabilityGroupName, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, managedInstanceName, distributedAvailabilityGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string managedInstanceName, string distributedAvailabilityGroupName, DistributedAvailabilityGroupData parameters) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Sql/managedInstances/", false); + uri.AppendPath(managedInstanceName, true); + uri.AppendPath("/distributedAvailabilityGroups/", false); + uri.AppendPath(distributedAvailabilityGroupName, true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(parameters); + request.Content = content; + message.SetProperty("UserAgentOverride", _userAgent); + return message; + } + + /// Updates a distributed availability group replication mode. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The distributed availability group name. + /// The distributed availability group info. + /// The cancellation token to use. + /// , , , , or is null. + public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string managedInstanceName, string distributedAvailabilityGroupName, DistributedAvailabilityGroupData parameters, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, managedInstanceName, distributedAvailabilityGroupName, parameters); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Updates a distributed availability group replication mode. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The distributed availability group name. + /// The distributed availability group info. + /// The cancellation token to use. + /// , , , , or is null. + public Response Update(string subscriptionId, string resourceGroupName, string managedInstanceName, string distributedAvailabilityGroupName, DistributedAvailabilityGroupData parameters, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + if (distributedAvailabilityGroupName == null) + { + throw new ArgumentNullException(nameof(distributedAvailabilityGroupName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, managedInstanceName, distributedAvailabilityGroupName, parameters); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByInstanceNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string managedInstanceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + message.SetProperty("UserAgentOverride", _userAgent); + return message; + } + + /// Gets a list of a distributed availability groups in instance. + /// The URL to the next page of results. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The cancellation token to use. + /// , , , or is null. + public async Task> ListByInstanceNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string managedInstanceName, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + + using var message = CreateListByInstanceNextPageRequest(nextLink, subscriptionId, resourceGroupName, managedInstanceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DistributedAvailabilityGroupsListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DistributedAvailabilityGroupsListResult.DeserializeDistributedAvailabilityGroupsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of a distributed availability groups in instance. + /// The URL to the next page of results. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The cancellation token to use. + /// , , , or is null. + public Response ListByInstanceNextPage(string nextLink, string subscriptionId, string resourceGroupName, string managedInstanceName, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + + using var message = CreateListByInstanceNextPageRequest(nextLink, subscriptionId, resourceGroupName, managedInstanceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DistributedAvailabilityGroupsListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DistributedAvailabilityGroupsListResult.DeserializeDistributedAvailabilityGroupsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/LongTermRetentionBackupsRestOperations.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/LongTermRetentionBackupsRestOperations.cs index ff88cf6466c4..06cdf0f3430d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/LongTermRetentionBackupsRestOperations.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/LongTermRetentionBackupsRestOperations.cs @@ -55,7 +55,7 @@ internal HttpMessage CreateCopyRequest(string subscriptionId, string locationNam uri.AppendPath("/longTermRetentionBackups/", false); uri.AppendPath(backupName, true); uri.AppendPath("/copy", false); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); @@ -180,7 +180,7 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string locationN uri.AppendPath("/longTermRetentionBackups/", false); uri.AppendPath(backupName, true); uri.AppendPath("/update", false); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); @@ -304,7 +304,7 @@ internal HttpMessage CreateGetRequest(string subscriptionId, string locationName uri.AppendPath(longTermRetentionDatabaseName, true); uri.AppendPath("/longTermRetentionBackups/", false); uri.AppendPath(backupName, true); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -426,7 +426,7 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string locationN uri.AppendPath(longTermRetentionDatabaseName, true); uri.AppendPath("/longTermRetentionBackups/", false); uri.AppendPath(backupName, true); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; message.SetProperty("UserAgentOverride", _userAgent); return message; @@ -542,7 +542,7 @@ internal HttpMessage CreateListByDatabaseRequest(string subscriptionId, string l { uri.AppendQuery("databaseState", databaseState.Value.ToString(), true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -657,7 +657,7 @@ internal HttpMessage CreateListByLocationRequest(string subscriptionId, string l { uri.AppendQuery("databaseState", databaseState.Value.ToString(), true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -754,7 +754,7 @@ internal HttpMessage CreateListByServerRequest(string subscriptionId, string loc { uri.AppendQuery("databaseState", databaseState.Value.ToString(), true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -859,7 +859,7 @@ internal HttpMessage CreateCopyByResourceGroupRequest(string subscriptionId, str uri.AppendPath("/longTermRetentionBackups/", false); uri.AppendPath(backupName, true); uri.AppendPath("/copy", false); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); @@ -996,7 +996,7 @@ internal HttpMessage CreateUpdateByResourceGroupRequest(string subscriptionId, s uri.AppendPath("/longTermRetentionBackups/", false); uri.AppendPath(backupName, true); uri.AppendPath("/update", false); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); @@ -1132,7 +1132,7 @@ internal HttpMessage CreateGetByResourceGroupRequest(string subscriptionId, stri uri.AppendPath(longTermRetentionDatabaseName, true); uri.AppendPath("/longTermRetentionBackups/", false); uri.AppendPath(backupName, true); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -1266,7 +1266,7 @@ internal HttpMessage CreateDeleteByResourceGroupRequest(string subscriptionId, s uri.AppendPath(longTermRetentionDatabaseName, true); uri.AppendPath("/longTermRetentionBackups/", false); uri.AppendPath(backupName, true); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; message.SetProperty("UserAgentOverride", _userAgent); return message; @@ -1394,7 +1394,7 @@ internal HttpMessage CreateListByResourceGroupDatabaseRequest(string subscriptio { uri.AppendQuery("databaseState", databaseState.Value.ToString(), true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -1521,7 +1521,7 @@ internal HttpMessage CreateListByResourceGroupLocationRequest(string subscriptio { uri.AppendQuery("databaseState", databaseState.Value.ToString(), true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -1630,7 +1630,7 @@ internal HttpMessage CreateListByResourceGroupServerRequest(string subscriptionI { uri.AppendQuery("databaseState", databaseState.Value.ToString(), true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/LongTermRetentionManagedInstanceBackupsRestOperations.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/LongTermRetentionManagedInstanceBackupsRestOperations.cs index 1b953c77bac7..95a43fa04c45 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/LongTermRetentionManagedInstanceBackupsRestOperations.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/LongTermRetentionManagedInstanceBackupsRestOperations.cs @@ -54,7 +54,7 @@ internal HttpMessage CreateGetRequest(string subscriptionId, string locationName uri.AppendPath(databaseName, true); uri.AppendPath("/longTermRetentionManagedInstanceBackups/", false); uri.AppendPath(backupName, true); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -176,7 +176,7 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string locationN uri.AppendPath(databaseName, true); uri.AppendPath("/longTermRetentionManagedInstanceBackups/", false); uri.AppendPath(backupName, true); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; message.SetProperty("UserAgentOverride", _userAgent); return message; @@ -292,7 +292,7 @@ internal HttpMessage CreateListByDatabaseRequest(string subscriptionId, string l { uri.AppendQuery("databaseState", databaseState.Value.ToString(), true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -409,7 +409,7 @@ internal HttpMessage CreateListByInstanceRequest(string subscriptionId, string l { uri.AppendQuery("databaseState", databaseState.Value.ToString(), true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -514,7 +514,7 @@ internal HttpMessage CreateListByLocationRequest(string subscriptionId, string l { uri.AppendQuery("databaseState", databaseState.Value.ToString(), true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -608,7 +608,7 @@ internal HttpMessage CreateGetByResourceGroupRequest(string subscriptionId, stri uri.AppendPath(databaseName, true); uri.AppendPath("/longTermRetentionManagedInstanceBackups/", false); uri.AppendPath(backupName, true); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -742,7 +742,7 @@ internal HttpMessage CreateDeleteByResourceGroupRequest(string subscriptionId, s uri.AppendPath(databaseName, true); uri.AppendPath("/longTermRetentionManagedInstanceBackups/", false); uri.AppendPath(backupName, true); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; message.SetProperty("UserAgentOverride", _userAgent); return message; @@ -870,7 +870,7 @@ internal HttpMessage CreateListByResourceGroupDatabaseRequest(string subscriptio { uri.AppendQuery("databaseState", databaseState.Value.ToString(), true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -999,7 +999,7 @@ internal HttpMessage CreateListByResourceGroupInstanceRequest(string subscriptio { uri.AppendQuery("databaseState", databaseState.Value.ToString(), true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -1116,7 +1116,7 @@ internal HttpMessage CreateListByResourceGroupLocationRequest(string subscriptio { uri.AppendQuery("databaseState", databaseState.Value.ToString(), true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/ManagedInstancesRestOperations.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/ManagedInstancesRestOperations.cs index e783cb211614..8039daefd500 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/ManagedInstancesRestOperations.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/ManagedInstancesRestOperations.cs @@ -55,7 +55,7 @@ internal HttpMessage CreateListByInstancePoolRequest(string subscriptionId, stri { uri.AppendQuery("$expand", expand, true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -152,7 +152,7 @@ internal HttpMessage CreateListRequest(string subscriptionId, string expand) { uri.AppendQuery("$expand", expand, true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -231,7 +231,7 @@ internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, str { uri.AppendQuery("$expand", expand, true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -321,7 +321,7 @@ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGrou { uri.AppendQuery("$expand", expand, true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -421,7 +421,7 @@ internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string r uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Sql/managedInstances/", false); uri.AppendPath(managedInstanceName, true); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); @@ -523,7 +523,7 @@ internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceG uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Sql/managedInstances/", false); uri.AppendPath(managedInstanceName, true); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; message.SetProperty("UserAgentOverride", _userAgent); return message; @@ -610,7 +610,7 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Sql/managedInstances/", false); uri.AppendPath(managedInstanceName, true); - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); @@ -739,7 +739,7 @@ internal HttpMessage CreateListByManagedInstanceRequest(string subscriptionId, s { uri.AppendQuery("observationMetric", observationMetric.Value.ToString(), true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -852,7 +852,7 @@ internal HttpMessage CreateFailoverRequest(string subscriptionId, string resourc { uri.AppendQuery("replicaType", replicaType.Value.ToString(), true); } - uri.AppendQuery("api-version", "2020-11-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; message.SetProperty("UserAgentOverride", _userAgent); return message; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/OperationsHealthRestOperations.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/OperationsHealthRestOperations.cs deleted file mode 100644 index 9b292c7c8bb2..000000000000 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/OperationsHealthRestOperations.cs +++ /dev/null @@ -1,211 +0,0 @@ -// 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.Core; -using Azure.ResourceManager.Sql.Models; - -namespace Azure.ResourceManager.Sql -{ - internal partial class OperationsHealthRestOperations - { - private Uri endpoint; - private ClientDiagnostics _clientDiagnostics; - private HttpPipeline _pipeline; - private readonly string _userAgent; - - /// Initializes a new instance of OperationsHealthRestOperations. - /// The handler for diagnostic messaging in the client. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The client options used to construct the current client. - /// server parameter. - public OperationsHealthRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, ClientOptions options, Uri endpoint = null) - { - this.endpoint = endpoint ?? new Uri("https://management.azure.com"); - _clientDiagnostics = clientDiagnostics; - _pipeline = pipeline; - _userAgent = HttpMessageUtilities.GetUserAgentName(this, options); - } - - internal HttpMessage CreateListByLocationRequest(string subscriptionId, string locationName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.Sql/locations/", false); - uri.AppendPath(locationName, true); - uri.AppendPath("/operationsHealth", false); - uri.AppendQuery("api-version", "2020-11-01-preview", true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - message.SetProperty("UserAgentOverride", _userAgent); - return message; - } - - /// Gets a service operation health status. - /// The subscription ID that identifies an Azure subscription. - /// The name of the region where the resource is located. - /// The cancellation token to use. - /// or is null. - public async Task> ListByLocationAsync(string subscriptionId, string locationName, CancellationToken cancellationToken = default) - { - if (subscriptionId == null) - { - throw new ArgumentNullException(nameof(subscriptionId)); - } - if (locationName == null) - { - throw new ArgumentNullException(nameof(locationName)); - } - - using var message = CreateListByLocationRequest(subscriptionId, locationName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - OperationsHealthListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = OperationsHealthListResult.DeserializeOperationsHealthListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a service operation health status. - /// The subscription ID that identifies an Azure subscription. - /// The name of the region where the resource is located. - /// The cancellation token to use. - /// or is null. - public Response ListByLocation(string subscriptionId, string locationName, CancellationToken cancellationToken = default) - { - if (subscriptionId == null) - { - throw new ArgumentNullException(nameof(subscriptionId)); - } - if (locationName == null) - { - throw new ArgumentNullException(nameof(locationName)); - } - - using var message = CreateListByLocationRequest(subscriptionId, locationName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - OperationsHealthListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = OperationsHealthListResult.DeserializeOperationsHealthListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - - internal HttpMessage CreateListByLocationNextPageRequest(string nextLink, string subscriptionId, string locationName) - { - 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"); - message.SetProperty("UserAgentOverride", _userAgent); - return message; - } - - /// Gets a service operation health status. - /// The URL to the next page of results. - /// The subscription ID that identifies an Azure subscription. - /// The name of the region where the resource is located. - /// The cancellation token to use. - /// , , or is null. - public async Task> ListByLocationNextPageAsync(string nextLink, string subscriptionId, string locationName, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - if (subscriptionId == null) - { - throw new ArgumentNullException(nameof(subscriptionId)); - } - if (locationName == null) - { - throw new ArgumentNullException(nameof(locationName)); - } - - using var message = CreateListByLocationNextPageRequest(nextLink, subscriptionId, locationName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - OperationsHealthListResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); - value = OperationsHealthListResult.DeserializeOperationsHealthListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); - } - } - - /// Gets a service operation health status. - /// The URL to the next page of results. - /// The subscription ID that identifies an Azure subscription. - /// The name of the region where the resource is located. - /// The cancellation token to use. - /// , , or is null. - public Response ListByLocationNextPage(string nextLink, string subscriptionId, string locationName, CancellationToken cancellationToken = default) - { - if (nextLink == null) - { - throw new ArgumentNullException(nameof(nextLink)); - } - if (subscriptionId == null) - { - throw new ArgumentNullException(nameof(subscriptionId)); - } - if (locationName == null) - { - throw new ArgumentNullException(nameof(locationName)); - } - - using var message = CreateListByLocationNextPageRequest(nextLink, subscriptionId, locationName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - OperationsHealthListResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream); - value = OperationsHealthListResult.DeserializeOperationsHealthListResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw _clientDiagnostics.CreateRequestFailedException(message.Response); - } - } - } -} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/RestorableDroppedDatabasesRestOperations.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/RestorableDroppedDatabasesRestOperations.cs index 9694b4f3c350..ab74ced9c015 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/RestorableDroppedDatabasesRestOperations.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/RestorableDroppedDatabasesRestOperations.cs @@ -51,7 +51,7 @@ internal HttpMessage CreateListByServerRequest(string subscriptionId, string res uri.AppendPath("/providers/Microsoft.Sql/servers/", false); uri.AppendPath(serverName, true); uri.AppendPath("/restorableDroppedDatabases", false); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -147,7 +147,7 @@ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGrou uri.AppendPath(serverName, true); uri.AppendPath("/restorableDroppedDatabases/", false); uri.AppendPath(restorableDroppedDatabaseId, true); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/RestorableDroppedManagedDatabasesRestOperations.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/RestorableDroppedManagedDatabasesRestOperations.cs index 67685f22f5c0..0b3bec4ea529 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/RestorableDroppedManagedDatabasesRestOperations.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/RestorableDroppedManagedDatabasesRestOperations.cs @@ -51,7 +51,7 @@ internal HttpMessage CreateListByInstanceRequest(string subscriptionId, string r uri.AppendPath("/providers/Microsoft.Sql/managedInstances/", false); uri.AppendPath(managedInstanceName, true); uri.AppendPath("/restorableDroppedDatabases", false); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); @@ -147,7 +147,7 @@ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGrou uri.AppendPath(managedInstanceName, true); uri.AppendPath("/restorableDroppedDatabases/", false); uri.AppendPath(restorableDroppedDatabaseId, true); - uri.AppendQuery("api-version", "2021-02-01-preview", true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); message.SetProperty("UserAgentOverride", _userAgent); diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/ServerTrustCertificatesRestOperations.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/ServerTrustCertificatesRestOperations.cs new file mode 100644 index 000000000000..5a9a47677be3 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestOperations/ServerTrustCertificatesRestOperations.cs @@ -0,0 +1,556 @@ +// 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.Core; +using Azure.ResourceManager.Sql.Models; + +namespace Azure.ResourceManager.Sql +{ + internal partial class ServerTrustCertificatesRestOperations + { + private Uri endpoint; + private ClientDiagnostics _clientDiagnostics; + private HttpPipeline _pipeline; + private readonly string _userAgent; + + /// Initializes a new instance of ServerTrustCertificatesRestOperations. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The client options used to construct the current client. + /// server parameter. + public ServerTrustCertificatesRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, ClientOptions options, Uri endpoint = null) + { + this.endpoint = endpoint ?? new Uri("https://management.azure.com"); + _clientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _userAgent = HttpMessageUtilities.GetUserAgentName(this, options); + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string managedInstanceName, string certificateName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Sql/managedInstances/", false); + uri.AppendPath(managedInstanceName, true); + uri.AppendPath("/serverTrustCertificates/", false); + uri.AppendPath(certificateName, true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + message.SetProperty("UserAgentOverride", _userAgent); + return message; + } + + /// Gets a server trust certificate that was uploaded from box to Sql Managed Instance. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// Name of of the certificate to get. + /// The cancellation token to use. + /// , , , or is null. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string managedInstanceName, string certificateName, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + if (certificateName == null) + { + throw new ArgumentNullException(nameof(certificateName)); + } + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, managedInstanceName, certificateName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ServerTrustCertificateData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ServerTrustCertificateData.DeserializeServerTrustCertificateData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ServerTrustCertificateData)null, message.Response); + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a server trust certificate that was uploaded from box to Sql Managed Instance. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// Name of of the certificate to get. + /// The cancellation token to use. + /// , , , or is null. + public Response Get(string subscriptionId, string resourceGroupName, string managedInstanceName, string certificateName, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + if (certificateName == null) + { + throw new ArgumentNullException(nameof(certificateName)); + } + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, managedInstanceName, certificateName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ServerTrustCertificateData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ServerTrustCertificateData.DeserializeServerTrustCertificateData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((ServerTrustCertificateData)null, message.Response); + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string managedInstanceName, string certificateName, ServerTrustCertificateData parameters) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Sql/managedInstances/", false); + uri.AppendPath(managedInstanceName, true); + uri.AppendPath("/serverTrustCertificates/", false); + uri.AppendPath(certificateName, true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(parameters); + request.Content = content; + message.SetProperty("UserAgentOverride", _userAgent); + return message; + } + + /// Uploads a server trust certificate from box to Sql Managed Instance. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// Name of of the certificate to upload. + /// The server trust certificate info. + /// The cancellation token to use. + /// , , , , or is null. + public async Task CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string managedInstanceName, string certificateName, ServerTrustCertificateData parameters, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + if (certificateName == null) + { + throw new ArgumentNullException(nameof(certificateName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, managedInstanceName, certificateName, parameters); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + case 202: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Uploads a server trust certificate from box to Sql Managed Instance. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// Name of of the certificate to upload. + /// The server trust certificate info. + /// The cancellation token to use. + /// , , , , or is null. + public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string managedInstanceName, string certificateName, ServerTrustCertificateData parameters, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + if (certificateName == null) + { + throw new ArgumentNullException(nameof(certificateName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, managedInstanceName, certificateName, parameters); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + case 202: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string managedInstanceName, string certificateName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Sql/managedInstances/", false); + uri.AppendPath(managedInstanceName, true); + uri.AppendPath("/serverTrustCertificates/", false); + uri.AppendPath(certificateName, true); + uri.AppendQuery("api-version", "2021-05-01-preview", true); + request.Uri = uri; + message.SetProperty("UserAgentOverride", _userAgent); + return message; + } + + /// Deletes a server trust certificate that was uploaded from box to Sql Managed Instance. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// Name of of the certificate to delete. + /// The cancellation token to use. + /// , , , or is null. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string managedInstanceName, string certificateName, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + if (certificateName == null) + { + throw new ArgumentNullException(nameof(certificateName)); + } + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, managedInstanceName, certificateName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Deletes a server trust certificate that was uploaded from box to Sql Managed Instance. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// Name of of the certificate to delete. + /// The cancellation token to use. + /// , , , or is null. + public Response Delete(string subscriptionId, string resourceGroupName, string managedInstanceName, string certificateName, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + if (certificateName == null) + { + throw new ArgumentNullException(nameof(certificateName)); + } + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, managedInstanceName, certificateName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + case 204: + return message.Response; + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByInstanceRequest(string subscriptionId, string resourceGroupName, string managedInstanceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Sql/managedInstances/", false); + uri.AppendPath(managedInstanceName, true); + uri.AppendPath("/serverTrustCertificates", false); + uri.AppendQuery("api-version", "2021-05-01-preview", true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + message.SetProperty("UserAgentOverride", _userAgent); + return message; + } + + /// Gets a list of the server trust certificates which are used for secure communication between SQL On-Prem instance and the given Sql Managed Instance. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The cancellation token to use. + /// , , or is null. + public async Task> ListByInstanceAsync(string subscriptionId, string resourceGroupName, string managedInstanceName, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + + using var message = CreateListByInstanceRequest(subscriptionId, resourceGroupName, managedInstanceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ServerTrustCertificatesListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ServerTrustCertificatesListResult.DeserializeServerTrustCertificatesListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of the server trust certificates which are used for secure communication between SQL On-Prem instance and the given Sql Managed Instance. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The cancellation token to use. + /// , , or is null. + public Response ListByInstance(string subscriptionId, string resourceGroupName, string managedInstanceName, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + + using var message = CreateListByInstanceRequest(subscriptionId, resourceGroupName, managedInstanceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ServerTrustCertificatesListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ServerTrustCertificatesListResult.DeserializeServerTrustCertificatesListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + + internal HttpMessage CreateListByInstanceNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string managedInstanceName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + message.SetProperty("UserAgentOverride", _userAgent); + return message; + } + + /// Gets a list of the server trust certificates which are used for secure communication between SQL On-Prem instance and the given Sql Managed Instance. + /// The URL to the next page of results. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The cancellation token to use. + /// , , , or is null. + public async Task> ListByInstanceNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string managedInstanceName, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + + using var message = CreateListByInstanceNextPageRequest(nextLink, subscriptionId, resourceGroupName, managedInstanceName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + ServerTrustCertificatesListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = ServerTrustCertificatesListResult.DeserializeServerTrustCertificatesListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); + } + } + + /// Gets a list of the server trust certificates which are used for secure communication between SQL On-Prem instance and the given Sql Managed Instance. + /// The URL to the next page of results. + /// The subscription ID that identifies an Azure subscription. + /// The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. + /// The name of the managed instance. + /// The cancellation token to use. + /// , , , or is null. + public Response ListByInstanceNextPage(string nextLink, string subscriptionId, string resourceGroupName, string managedInstanceName, CancellationToken cancellationToken = default) + { + if (nextLink == null) + { + throw new ArgumentNullException(nameof(nextLink)); + } + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (resourceGroupName == null) + { + throw new ArgumentNullException(nameof(resourceGroupName)); + } + if (managedInstanceName == null) + { + throw new ArgumentNullException(nameof(managedInstanceName)); + } + + using var message = CreateListByInstanceNextPageRequest(nextLink, subscriptionId, resourceGroupName, managedInstanceName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + ServerTrustCertificatesListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = ServerTrustCertificatesListResult.DeserializeServerTrustCertificatesListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw _clientDiagnostics.CreateRequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestorableDroppedDatabaseData.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestorableDroppedDatabaseData.cs index 468770e42781..fb965c2e51b5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestorableDroppedDatabaseData.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/RestorableDroppedDatabaseData.cs @@ -31,19 +31,17 @@ public RestorableDroppedDatabaseData() /// Resource tags. /// The name of the database. /// The max size of the database expressed in bytes. - /// DEPRECATED: The resource name of the elastic pool containing this database. This property is deprecated and the value will always be null. /// The creation date of the database (ISO8601 format). /// The deletion date of the database (ISO8601 format). /// The earliest restore date of the database (ISO8601 format). /// The storage account type used to store backups for this database. - internal RestorableDroppedDatabaseData(ResourceIdentifier id, string name, ResourceType type, Models.Sku sku, string location, IDictionary tags, string databaseName, long? maxSizeBytes, string elasticPoolId, DateTimeOffset? creationDate, DateTimeOffset? deletionDate, DateTimeOffset? earliestRestoreDate, RestorableDroppedDatabasePropertiesBackupStorageRedundancy? backupStorageRedundancy) : base(id, name, type) + internal RestorableDroppedDatabaseData(ResourceIdentifier id, string name, ResourceType type, Models.Sku sku, string location, IDictionary tags, string databaseName, long? maxSizeBytes, DateTimeOffset? creationDate, DateTimeOffset? deletionDate, DateTimeOffset? earliestRestoreDate, BackupStorageRedundancy? backupStorageRedundancy) : base(id, name, type) { Sku = sku; Location = location; Tags = tags; DatabaseName = databaseName; MaxSizeBytes = maxSizeBytes; - ElasticPoolId = elasticPoolId; CreationDate = creationDate; DeletionDate = deletionDate; EarliestRestoreDate = earliestRestoreDate; @@ -60,8 +58,6 @@ internal RestorableDroppedDatabaseData(ResourceIdentifier id, string name, Resou public string DatabaseName { get; } /// The max size of the database expressed in bytes. public long? MaxSizeBytes { get; } - /// DEPRECATED: The resource name of the elastic pool containing this database. This property is deprecated and the value will always be null. - public string ElasticPoolId { get; } /// The creation date of the database (ISO8601 format). public DateTimeOffset? CreationDate { get; } /// The deletion date of the database (ISO8601 format). @@ -69,6 +65,6 @@ internal RestorableDroppedDatabaseData(ResourceIdentifier id, string name, Resou /// The earliest restore date of the database (ISO8601 format). public DateTimeOffset? EarliestRestoreDate { get; } /// The storage account type used to store backups for this database. - public RestorableDroppedDatabasePropertiesBackupStorageRedundancy? BackupStorageRedundancy { get; } + public BackupStorageRedundancy? BackupStorageRedundancy { get; } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerTrustCertificate.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerTrustCertificate.cs new file mode 100644 index 000000000000..bd6311f48a6e --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerTrustCertificate.cs @@ -0,0 +1,217 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.Core; +using Azure.ResourceManager.Sql.Models; + +namespace Azure.ResourceManager.Sql +{ + /// A Class representing a ServerTrustCertificate along with the instance operations that can be performed on it. + public partial class ServerTrustCertificate : ArmResource + { + /// Generate the resource identifier of a instance. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string managedInstanceName, string certificateName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName}"; + return new ResourceIdentifier(resourceId); + } + private readonly ClientDiagnostics _clientDiagnostics; + private readonly ServerTrustCertificatesRestOperations _serverTrustCertificatesRestClient; + private readonly ServerTrustCertificateData _data; + + /// Initializes a new instance of the class for mocking. + protected ServerTrustCertificate() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal ServerTrustCertificate(ArmResource options, ServerTrustCertificateData resource) : base(options, resource.Id) + { + HasData = true; + _data = resource; + _clientDiagnostics = new ClientDiagnostics(ClientOptions); + _serverTrustCertificatesRestClient = new ServerTrustCertificatesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// 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 ServerTrustCertificate(ArmResource options, ResourceIdentifier id) : base(options, id) + { + _clientDiagnostics = new ClientDiagnostics(ClientOptions); + _serverTrustCertificatesRestClient = new ServerTrustCertificatesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Initializes a new instance of the class. + /// The client options to build client context. + /// The credential to build client context. + /// The uri to build client context. + /// The pipeline to build client context. + /// The identifier of the resource that is the target of operations. + internal ServerTrustCertificate(ArmClientOptions clientOptions, TokenCredential credential, Uri uri, HttpPipeline pipeline, ResourceIdentifier id) : base(clientOptions, credential, uri, pipeline, id) + { + _clientDiagnostics = new ClientDiagnostics(ClientOptions); + _serverTrustCertificatesRestClient = new ServerTrustCertificatesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Sql/managedInstances/serverTrustCertificates"; + + /// 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 ServerTrustCertificateData 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)); + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName} + /// OperationId: ServerTrustCertificates_Get + /// Gets a server trust certificate that was uploaded from box to Sql Managed Instance. + /// The cancellation token to use. + public async virtual Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ServerTrustCertificate.Get"); + scope.Start(); + try + { + var response = await _serverTrustCertificatesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); + return Response.FromValue(new ServerTrustCertificate(this, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName} + /// OperationId: ServerTrustCertificates_Get + /// Gets a server trust certificate that was uploaded from box to Sql Managed Instance. + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ServerTrustCertificate.Get"); + scope.Start(); + try + { + var response = _serverTrustCertificatesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ServerTrustCertificate(this, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Lists all available geo-locations. + /// A token to allow the caller to cancel the call to the service. The default value is . + /// A collection of locations that may take multiple service requests to iterate over. + public async virtual Task> GetAvailableLocationsAsync(CancellationToken cancellationToken = default) + { + return await ListAvailableLocationsAsync(ResourceType, cancellationToken).ConfigureAwait(false); + } + + /// Lists all available geo-locations. + /// A token to allow the caller to cancel the call to the service. The default value is . + /// A collection of locations that may take multiple service requests to iterate over. + public virtual IEnumerable GetAvailableLocations(CancellationToken cancellationToken = default) + { + return ListAvailableLocations(ResourceType, cancellationToken); + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName} + /// OperationId: ServerTrustCertificates_Delete + /// Deletes a server trust certificate that was uploaded from box to Sql Managed Instance. + /// Waits for the completion of the long running operations. + /// The cancellation token to use. + public async virtual Task DeleteAsync(bool waitForCompletion = true, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ServerTrustCertificate.Delete"); + scope.Start(); + try + { + var response = await _serverTrustCertificatesRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new ServerTrustCertificateDeleteOperation(_clientDiagnostics, Pipeline, _serverTrustCertificatesRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response); + if (waitForCompletion) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName} + /// OperationId: ServerTrustCertificates_Delete + /// Deletes a server trust certificate that was uploaded from box to Sql Managed Instance. + /// Waits for the completion of the long running operations. + /// The cancellation token to use. + public virtual ServerTrustCertificateDeleteOperation Delete(bool waitForCompletion = true, CancellationToken cancellationToken = default) + { + using var scope = _clientDiagnostics.CreateScope("ServerTrustCertificate.Delete"); + scope.Start(); + try + { + var response = _serverTrustCertificatesRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var operation = new ServerTrustCertificateDeleteOperation(_clientDiagnostics, Pipeline, _serverTrustCertificatesRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name).Request, response); + if (waitForCompletion) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerTrustCertificateCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerTrustCertificateCollection.cs new file mode 100644 index 000000000000..0e31bad69486 --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerTrustCertificateCollection.cs @@ -0,0 +1,391 @@ +// 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.Core; +using Azure.ResourceManager.Sql.Models; + +namespace Azure.ResourceManager.Sql +{ + /// A class representing collection of ServerTrustCertificate and their operations over its parent. + public partial class ServerTrustCertificateCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _clientDiagnostics; + private readonly ServerTrustCertificatesRestOperations _serverTrustCertificatesRestClient; + + /// Initializes a new instance of the class for mocking. + protected ServerTrustCertificateCollection() + { + } + + /// Initializes a new instance of ServerTrustCertificateCollection class. + /// The resource representing the parent resource. + internal ServerTrustCertificateCollection(ArmResource parent) : base(parent) + { + _clientDiagnostics = new ClientDiagnostics(ClientOptions); + _serverTrustCertificatesRestClient = new ServerTrustCertificatesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ManagedInstance.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ManagedInstance.ResourceType), nameof(id)); + } + + // Collection level operations. + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: ServerTrustCertificates_CreateOrUpdate + /// Uploads a server trust certificate from box to Sql Managed Instance. + /// Name of of the certificate to upload. + /// The server trust certificate info. + /// Waits for the completion of the long running operations. + /// The cancellation token to use. + /// or is null. + public virtual ServerTrustCertificateCreateOrUpdateOperation CreateOrUpdate(string certificateName, ServerTrustCertificateData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) + { + if (certificateName == null) + { + throw new ArgumentNullException(nameof(certificateName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var scope = _clientDiagnostics.CreateScope("ServerTrustCertificateCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _serverTrustCertificatesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, parameters, cancellationToken); + var operation = new ServerTrustCertificateCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _serverTrustCertificatesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, parameters).Request, response); + if (waitForCompletion) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: ServerTrustCertificates_CreateOrUpdate + /// Uploads a server trust certificate from box to Sql Managed Instance. + /// Name of of the certificate to upload. + /// The server trust certificate info. + /// Waits for the completion of the long running operations. + /// The cancellation token to use. + /// or is null. + public async virtual Task CreateOrUpdateAsync(string certificateName, ServerTrustCertificateData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) + { + if (certificateName == null) + { + throw new ArgumentNullException(nameof(certificateName)); + } + if (parameters == null) + { + throw new ArgumentNullException(nameof(parameters)); + } + + using var scope = _clientDiagnostics.CreateScope("ServerTrustCertificateCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _serverTrustCertificatesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, parameters, cancellationToken).ConfigureAwait(false); + var operation = new ServerTrustCertificateCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _serverTrustCertificatesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, parameters).Request, response); + if (waitForCompletion) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: ServerTrustCertificates_Get + /// Gets a server trust certificate that was uploaded from box to Sql Managed Instance. + /// Name of of the certificate to get. + /// The cancellation token to use. + /// is null. + public virtual Response Get(string certificateName, CancellationToken cancellationToken = default) + { + if (certificateName == null) + { + throw new ArgumentNullException(nameof(certificateName)); + } + + using var scope = _clientDiagnostics.CreateScope("ServerTrustCertificateCollection.Get"); + scope.Start(); + try + { + var response = _serverTrustCertificatesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, cancellationToken); + if (response.Value == null) + throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); + return Response.FromValue(new ServerTrustCertificate(Parent, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates/{certificateName} + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: ServerTrustCertificates_Get + /// Gets a server trust certificate that was uploaded from box to Sql Managed Instance. + /// Name of of the certificate to get. + /// The cancellation token to use. + /// is null. + public async virtual Task> GetAsync(string certificateName, CancellationToken cancellationToken = default) + { + if (certificateName == null) + { + throw new ArgumentNullException(nameof(certificateName)); + } + + using var scope = _clientDiagnostics.CreateScope("ServerTrustCertificateCollection.Get"); + scope.Start(); + try + { + var response = await _serverTrustCertificatesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); + return Response.FromValue(new ServerTrustCertificate(Parent, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Tries to get details for this resource from the service. + /// Name of of the certificate to get. + /// The cancellation token to use. + /// is null. + public virtual Response GetIfExists(string certificateName, CancellationToken cancellationToken = default) + { + if (certificateName == null) + { + throw new ArgumentNullException(nameof(certificateName)); + } + + using var scope = _clientDiagnostics.CreateScope("ServerTrustCertificateCollection.GetIfExists"); + scope.Start(); + try + { + var response = _serverTrustCertificatesRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, cancellationToken: cancellationToken); + return response.Value == null + ? Response.FromValue(null, response.GetRawResponse()) + : Response.FromValue(new ServerTrustCertificate(this, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Tries to get details for this resource from the service. + /// Name of of the certificate to get. + /// The cancellation token to use. + /// is null. + public async virtual Task> GetIfExistsAsync(string certificateName, CancellationToken cancellationToken = default) + { + if (certificateName == null) + { + throw new ArgumentNullException(nameof(certificateName)); + } + + using var scope = _clientDiagnostics.CreateScope("ServerTrustCertificateCollection.GetIfExistsAsync"); + scope.Start(); + try + { + var response = await _serverTrustCertificatesRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, certificateName, cancellationToken: cancellationToken).ConfigureAwait(false); + return response.Value == null + ? Response.FromValue(null, response.GetRawResponse()) + : Response.FromValue(new ServerTrustCertificate(this, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Tries to get details for this resource from the service. + /// Name of of the certificate to get. + /// The cancellation token to use. + /// is null. + public virtual Response Exists(string certificateName, CancellationToken cancellationToken = default) + { + if (certificateName == null) + { + throw new ArgumentNullException(nameof(certificateName)); + } + + using var scope = _clientDiagnostics.CreateScope("ServerTrustCertificateCollection.Exists"); + scope.Start(); + try + { + var response = GetIfExists(certificateName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Tries to get details for this resource from the service. + /// Name of of the certificate to get. + /// The cancellation token to use. + /// is null. + public async virtual Task> ExistsAsync(string certificateName, CancellationToken cancellationToken = default) + { + if (certificateName == null) + { + throw new ArgumentNullException(nameof(certificateName)); + } + + using var scope = _clientDiagnostics.CreateScope("ServerTrustCertificateCollection.ExistsAsync"); + scope.Start(); + try + { + var response = await GetIfExistsAsync(certificateName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: ServerTrustCertificates_ListByInstance + /// Gets a list of the server trust certificates which are used for secure communication between SQL On-Prem instance and the given Sql Managed Instance. + /// 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 = _clientDiagnostics.CreateScope("ServerTrustCertificateCollection.GetAll"); + scope.Start(); + try + { + var response = _serverTrustCertificatesRestClient.ListByInstance(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value.Select(value => new ServerTrustCertificate(Parent, value)), response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + Page NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ServerTrustCertificateCollection.GetAll"); + scope.Start(); + try + { + var response = _serverTrustCertificatesRestClient.ListByInstanceNextPage(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken); + return Page.FromValues(response.Value.Value.Select(value => new ServerTrustCertificate(Parent, value)), response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); + } + + /// RequestPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustCertificates + /// ContextualPath: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName} + /// OperationId: ServerTrustCertificates_ListByInstance + /// Gets a list of the server trust certificates which are used for secure communication between SQL On-Prem instance and the given Sql Managed Instance. + /// 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 = _clientDiagnostics.CreateScope("ServerTrustCertificateCollection.GetAll"); + scope.Start(); + try + { + var response = await _serverTrustCertificatesRestClient.ListByInstanceAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value.Select(value => new ServerTrustCertificate(Parent, value)), response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + async Task> NextPageFunc(string nextLink, int? pageSizeHint) + { + using var scope = _clientDiagnostics.CreateScope("ServerTrustCertificateCollection.GetAll"); + scope.Start(); + try + { + var response = await _serverTrustCertificatesRestClient.ListByInstanceNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken: cancellationToken).ConfigureAwait(false); + return Page.FromValues(response.Value.Value.Select(value => new ServerTrustCertificate(Parent, value)), response.Value.NextLink, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + + // Builders. + // public ArmBuilder Construct() { } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerTrustCertificateData.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerTrustCertificateData.cs new file mode 100644 index 000000000000..4fa1b52fda5f --- /dev/null +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/ServerTrustCertificateData.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Sql +{ + /// A class representing the ServerTrustCertificate data model. + public partial class ServerTrustCertificateData : Resource + { + /// Initializes a new instance of ServerTrustCertificateData. + public ServerTrustCertificateData() + { + } + + /// Initializes a new instance of ServerTrustCertificateData. + /// The id. + /// The name. + /// The type. + /// The certificate public blob. + /// The certificate thumbprint. + /// The certificate name. + internal ServerTrustCertificateData(ResourceIdentifier id, string name, ResourceType type, string publicBlob, string thumbprint, string certificateName) : base(id, name, type) + { + PublicBlob = publicBlob; + Thumbprint = thumbprint; + CertificateName = certificateName; + } + + /// The certificate public blob. + public string PublicBlob { get; set; } + /// The certificate thumbprint. + public string Thumbprint { get; } + /// The certificate name. + public string CertificateName { get; } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseData.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseData.cs index 7debbb7a8ad6..faafe38abecf 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseData.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/Generated/SqlDatabaseData.cs @@ -44,6 +44,7 @@ public SqlDatabaseData(AzureLocation location) : base(location) /// /// Kind of database. This is metadata used for the Azure portal experience. /// Resource that manages the database. + /// The Azure Active Directory identity of the database. /// /// Specifies the mode of database creation. /// @@ -99,11 +100,14 @@ public SqlDatabaseData(AzureLocation location) : base(location) /// Maintenance configuration id assigned to the database. This configuration defines the period when the maintenance updates will occur. /// Whether or not this database is a ledger database, which means all tables in the database are ledger tables. Note: the value of this property cannot be changed after the database has been created. /// Infra encryption is enabled for this database. - internal SqlDatabaseData(ResourceIdentifier id, string name, ResourceType type, IDictionary tags, AzureLocation location, Models.Sku sku, string kind, string managedBy, CreateMode? createMode, string collation, long? maxSizeBytes, SampleSchemaName? sampleName, string elasticPoolId, string sourceDatabaseId, DatabaseStatus? status, Guid? databaseId, DateTimeOffset? creationDate, string currentServiceObjectiveName, string requestedServiceObjectiveName, string defaultSecondaryLocation, string failoverGroupId, DateTimeOffset? restorePointInTime, DateTimeOffset? sourceDatabaseDeletionDate, string recoveryServicesRecoveryPointId, string longTermRetentionBackupResourceId, string recoverableDatabaseId, string restorableDroppedDatabaseId, CatalogCollationType? catalogCollation, bool? zoneRedundant, DatabaseLicenseType? licenseType, long? maxLogSizeBytes, DateTimeOffset? earliestRestoreDate, DatabaseReadScale? readScale, int? highAvailabilityReplicaCount, SecondaryType? secondaryType, Models.Sku currentSku, int? autoPauseDelay, CurrentBackupStorageRedundancy? currentBackupStorageRedundancy, RequestedBackupStorageRedundancy? requestedBackupStorageRedundancy, double? minCapacity, DateTimeOffset? pausedDate, DateTimeOffset? resumedDate, string maintenanceConfigurationId, bool? isLedgerOn, bool? isInfraEncryptionEnabled) : base(id, name, type, tags, location) + /// The Client id used for cross tenant per database CMK scenario. + /// The Primary Delegated Identity Client id used for per database CMK - for internal use only. + internal SqlDatabaseData(ResourceIdentifier id, string name, ResourceType type, IDictionary tags, AzureLocation location, Models.Sku sku, string kind, string managedBy, DatabaseIdentity identity, CreateMode? createMode, string collation, long? maxSizeBytes, SampleSchemaName? sampleName, string elasticPoolId, string sourceDatabaseId, DatabaseStatus? status, Guid? databaseId, DateTimeOffset? creationDate, string currentServiceObjectiveName, string requestedServiceObjectiveName, string defaultSecondaryLocation, string failoverGroupId, DateTimeOffset? restorePointInTime, DateTimeOffset? sourceDatabaseDeletionDate, string recoveryServicesRecoveryPointId, string longTermRetentionBackupResourceId, string recoverableDatabaseId, string restorableDroppedDatabaseId, CatalogCollationType? catalogCollation, bool? zoneRedundant, DatabaseLicenseType? licenseType, long? maxLogSizeBytes, DateTimeOffset? earliestRestoreDate, DatabaseReadScale? readScale, int? highAvailabilityReplicaCount, SecondaryType? secondaryType, Models.Sku currentSku, int? autoPauseDelay, BackupStorageRedundancy? currentBackupStorageRedundancy, BackupStorageRedundancy? requestedBackupStorageRedundancy, double? minCapacity, DateTimeOffset? pausedDate, DateTimeOffset? resumedDate, string maintenanceConfigurationId, bool? isLedgerOn, bool? isInfraEncryptionEnabled, Guid? federatedClientId, Guid? primaryDelegatedIdentityClientId) : base(id, name, type, tags, location) { Sku = sku; Kind = kind; ManagedBy = managedBy; + Identity = identity; CreateMode = createMode; Collation = collation; MaxSizeBytes = maxSizeBytes; @@ -141,6 +145,8 @@ internal SqlDatabaseData(ResourceIdentifier id, string name, ResourceType type, MaintenanceConfigurationId = maintenanceConfigurationId; IsLedgerOn = isLedgerOn; IsInfraEncryptionEnabled = isInfraEncryptionEnabled; + FederatedClientId = federatedClientId; + PrimaryDelegatedIdentityClientId = primaryDelegatedIdentityClientId; } /// @@ -162,6 +168,8 @@ internal SqlDatabaseData(ResourceIdentifier id, string name, ResourceType type, public string Kind { get; } /// Resource that manages the database. public string ManagedBy { get; } + /// The Azure Active Directory identity of the database. + public DatabaseIdentity Identity { get; set; } /// /// Specifies the mode of database creation. /// @@ -239,9 +247,9 @@ internal SqlDatabaseData(ResourceIdentifier id, string name, ResourceType type, /// Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled. public int? AutoPauseDelay { get; set; } /// The storage account type used to store backups for this database. - public CurrentBackupStorageRedundancy? CurrentBackupStorageRedundancy { get; } + public BackupStorageRedundancy? CurrentBackupStorageRedundancy { get; } /// The storage account type to be used to store backups for this database. - public RequestedBackupStorageRedundancy? RequestedBackupStorageRedundancy { get; set; } + public BackupStorageRedundancy? RequestedBackupStorageRedundancy { get; set; } /// Minimal capacity that database will always have allocated, if not paused. public double? MinCapacity { get; set; } /// The date when database was paused by user configuration or action(ISO8601 format). Null if the database is ready. @@ -254,5 +262,9 @@ internal SqlDatabaseData(ResourceIdentifier id, string name, ResourceType type, public bool? IsLedgerOn { get; set; } /// Infra encryption is enabled for this database. public bool? IsInfraEncryptionEnabled { get; } + /// The Client id used for cross tenant per database CMK scenario. + public Guid? FederatedClientId { get; set; } + /// The Primary Delegated Identity Client id used for per database CMK - for internal use only. + public Guid? PrimaryDelegatedIdentityClientId { get; set; } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/autorest.md b/sdk/sqlmanagement/Azure.ResourceManager.Sql/src/autorest.md index 503b03524f68..6f0c4ad27b19 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/4946dbb5b2893a77ce52d08e2a855056e1acd361/specification/sql/resource-manager/readme.md +require: https://github.com/Azure/azure-rest-api-specs/blob/eeb2d33f8087867f8bbf388ea2058c26e7581dd7/specification/sql/resource-manager/readme.md namespace: Azure.ResourceManager.Sql output-folder: $(this-folder)/Generated model-namespace: false