diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/ISqlManagementClient.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/ISqlManagementClient.cs new file mode 100644 index 000000000000..c5446b3cda5f --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/ISqlManagementClient.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2 +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// The Azure SQL Database management API provides a RESTful set of web APIs + /// that interact with Azure SQL Database services to manage your databases. + /// The API enables users to create, retrieve, update, and delete databases, + /// servers, and other entities. + /// + public partial interface ISqlManagementClient : System.IDisposable + { + /// + /// The base URI of the service. + /// + System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + Microsoft.Rest.ServiceClientCredentials Credentials { get;} + + + /// + /// The API version to use for this operation. + /// + string ApiVersion { get;} + + + /// + /// The subscription ID that identifies an Azure subscription. + /// + string SubscriptionId { get; set;} + + + /// + /// The preferred language for the response. + /// + string AcceptLanguage { get; set;} + + + /// + /// The retry timeout in seconds for Long Running Operations. Default + /// /// value is 30. + /// + int? LongRunningOperationRetryTimeout { get; set;} + + + /// + /// Whether a unique x-ms-client-request-id should be generated. When + /// /// set to true a unique x-ms-client-request-id value is generated and + /// /// included in each request. Default is true. + /// + bool? GenerateClientRequestId { get; set;} + + + /// + /// Gets the ISyncGroupsOperations + /// + ISyncGroupsOperations SyncGroups { get; } + + /// + /// Gets the ISyncMembersOperations + /// + ISyncMembersOperations SyncMembers { get; } + + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/ISyncGroupsOperations.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/ISyncGroupsOperations.cs new file mode 100644 index 000000000000..b9d0328c9ad9 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/ISyncGroupsOperations.cs @@ -0,0 +1,597 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2 +{ + using Microsoft.Rest.Azure; + using Models; + + /// + /// SyncGroupsOperations operations. + /// + public partial interface ISyncGroupsOperations + { + /// + /// Gets a collection of sync database ids. + /// + /// + /// Gets a collection of sync database ids. + /// + /// + /// The name of the region where the resource is located. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task>> ListSyncDatabaseIdsWithHttpMessagesAsync(string locationName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Lists sync groups under a hub database. + /// + /// + /// Lists sync groups under a hub database. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task>> ListByDatabaseWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Gets a sync group. + /// + /// + /// Gets a sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Creates or updates a sync group. + /// + /// + /// Creates or updates a sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The requested sync group resource state. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Deletes a sync group. + /// + /// + /// Deletes a sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + System.Threading.Tasks.Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Updates a sync group. + /// + /// + /// Updates a sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The requested sync group resource state. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Cancels a sync group synchronization. + /// + /// + /// Cancels a sync group synchronization. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + System.Threading.Tasks.Task CancelSyncWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Gets a collection of hub database schemas. + /// + /// + /// Gets a collection of hub database schemas. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task>> ListHubSchemasWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Gets a collection of sync group logs. + /// + /// + /// Gets a collection of sync group logs. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// Get logs generated after this time. + /// + /// + /// Get logs generated before this time. + /// + /// + /// The types of logs to retrieve. + /// + /// + /// The continuation token for this operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task>> ListLogsWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string startTime, string endTime, string type, string continuationToken = default(string), System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Refreshes a hub database schema. + /// + /// + /// Refreshes a hub database schema. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + System.Threading.Tasks.Task> RefreshHubSchemaWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Triggers a sync group synchronization. + /// + /// + /// Triggers a sync group synchronization. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + System.Threading.Tasks.Task TriggerSyncWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Creates or updates a sync group. + /// + /// + /// Creates or updates a sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The requested sync group resource state. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Deletes a sync group. + /// + /// + /// Deletes a sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + System.Threading.Tasks.Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Updates a sync group. + /// + /// + /// Updates a sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The requested sync group resource state. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Refreshes a hub database schema. + /// + /// + /// Refreshes a hub database schema. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + System.Threading.Tasks.Task> BeginRefreshHubSchemaWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Gets a collection of sync database ids. + /// + /// + /// Gets a collection of sync database ids. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task>> ListSyncDatabaseIdsNextWithHttpMessagesAsync(string nextPageLink, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Lists sync groups under a hub database. + /// + /// + /// Lists sync groups under a hub database. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task>> ListByDatabaseNextWithHttpMessagesAsync(string nextPageLink, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Gets a collection of hub database schemas. + /// + /// + /// Gets a collection of hub database schemas. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task>> ListHubSchemasNextWithHttpMessagesAsync(string nextPageLink, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Gets a collection of sync group logs. + /// + /// + /// Gets a collection of sync group logs. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task>> ListLogsNextWithHttpMessagesAsync(string nextPageLink, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/ISyncMembersOperations.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/ISyncMembersOperations.cs new file mode 100644 index 000000000000..3c8b0988873a --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/ISyncMembersOperations.cs @@ -0,0 +1,456 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2 +{ + using Microsoft.Rest.Azure; + using Models; + + /// + /// SyncMembersOperations operations. + /// + public partial interface ISyncMembersOperations + { + /// + /// Lists sync members in the given sync group. + /// + /// + /// Lists sync members in the given sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task>> ListBySyncGroupWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Gets a sync member. + /// + /// + /// Gets a sync member. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Creates or updates a sync member. + /// + /// + /// Creates or updates a sync member. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The requested sync member resource state. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Deletes a sync member. + /// + /// + /// Deletes a sync member. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + System.Threading.Tasks.Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Updates an existing sync member. + /// + /// + /// Updates an existing sync member. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The requested sync member resource state. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Refreshes a sync member database schema. + /// + /// + /// Refreshes a sync member database schema. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + System.Threading.Tasks.Task> RefreshMemberSchemaWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Gets a sync member database schema. + /// + /// + /// Gets a sync member database schema. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task>> ListMemberSchemasWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Creates or updates a sync member. + /// + /// + /// Creates or updates a sync member. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The requested sync member resource state. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Deletes a sync member. + /// + /// + /// Deletes a sync member. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + System.Threading.Tasks.Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Updates an existing sync member. + /// + /// + /// Updates an existing sync member. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The requested sync member resource state. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Refreshes a sync member database schema. + /// + /// + /// Refreshes a sync member database schema. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + System.Threading.Tasks.Task> BeginRefreshMemberSchemaWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Lists sync members in the given sync group. + /// + /// + /// Lists sync members in the given sync group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task>> ListBySyncGroupNextWithHttpMessagesAsync(string nextPageLink, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Gets a sync member database schema. + /// + /// + /// Gets a sync member database schema. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + System.Threading.Tasks.Task>> ListMemberSchemasNextWithHttpMessagesAsync(string nextPageLink, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/DataSyncParticipantIdentity.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/DataSyncParticipantIdentity.cs new file mode 100644 index 000000000000..f9d37ae345a4 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/DataSyncParticipantIdentity.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// Azure Active Directory identity configuration for a resource. + /// + public partial class DataSyncParticipantIdentity + { + /// + /// Initializes a new instance of the DataSyncParticipantIdentity class. + /// + public DataSyncParticipantIdentity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DataSyncParticipantIdentity class. + /// + + /// The Datasync identity type + /// Possible values include: 'None', 'SystemAssigned', 'UserAssigned', + /// 'SystemAssignedUserAssigned' + + /// The DataSync participant identity tenant id + /// + + /// The resource ids of the user assigned identities to use + /// + public DataSyncParticipantIdentity(string type, System.Guid? tenantId = default(System.Guid?), System.Collections.Generic.IDictionary userAssignedIdentities = default(System.Collections.Generic.IDictionary)) + + { + this.Type = type; + this.TenantId = tenantId; + this.UserAssignedIdentities = userAssignedIdentities; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets the Datasync identity type Possible values include: 'None', 'SystemAssigned', 'UserAssigned', 'SystemAssignedUserAssigned' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "type")] + public string Type {get; set; } + + /// + /// Gets or sets the DataSync participant identity tenant id + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "tenantId")] + public System.Guid? TenantId {get; set; } + + /// + /// Gets or sets the resource ids of the user assigned identities to use + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "userAssignedIdentities")] + public System.Collections.Generic.IDictionary UserAssignedIdentities {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (this.Type == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Type"); + } + + + } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/DataSyncParticipantIdentityType.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/DataSyncParticipantIdentityType.cs new file mode 100644 index 000000000000..8eea30847101 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/DataSyncParticipantIdentityType.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + + /// + /// Defines values for DataSyncParticipantIdentityType. + /// + + + public static class DataSyncParticipantIdentityType + { + public const string None = "None"; + public const string SystemAssigned = "SystemAssigned"; + public const string UserAssigned = "UserAssigned"; + public const string SystemAssignedUserAssigned = "SystemAssignedUserAssigned"; + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/DataSyncParticipantUserAssignedIdentity.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/DataSyncParticipantUserAssignedIdentity.cs new file mode 100644 index 000000000000..e44fa3f2974f --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/DataSyncParticipantUserAssignedIdentity.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// Azure Active Directory identity configuration for a resource. + /// + public partial class DataSyncParticipantUserAssignedIdentity + { + /// + /// Initializes a new instance of the DataSyncParticipantUserAssignedIdentity class. + /// + public DataSyncParticipantUserAssignedIdentity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DataSyncParticipantUserAssignedIdentity class. + /// + + /// The Azure Active Directory principal id. + /// + + /// The Azure Active Directory client id. + /// + public DataSyncParticipantUserAssignedIdentity(System.Guid? principalId = default(System.Guid?), System.Guid? clientId = default(System.Guid?)) + + { + this.PrincipalId = principalId; + this.ClientId = clientId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets the Azure Active Directory principal id. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "principalId")] + public System.Guid? PrincipalId {get; private set; } + + /// + /// Gets the Azure Active Directory client id. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "clientId")] + public System.Guid? ClientId {get; private set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ErrorAdditionalInfo.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ErrorAdditionalInfo.cs new file mode 100644 index 000000000000..4bbedcd7bf60 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ErrorAdditionalInfo.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// The resource management error additional info. + /// + public partial class ErrorAdditionalInfo + { + /// + /// Initializes a new instance of the ErrorAdditionalInfo class. + /// + public ErrorAdditionalInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorAdditionalInfo class. + /// + + /// The additional info type. + /// + + /// The additional info. + /// + public ErrorAdditionalInfo(string type = default(string), object info = default(object)) + + { + this.Type = type; + this.Info = info; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets the additional info type. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "type")] + public string Type {get; private set; } + + /// + /// Gets the additional info. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "info")] + public object Info {get; private set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ErrorDetail.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ErrorDetail.cs new file mode 100644 index 000000000000..18378326ce24 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ErrorDetail.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// The error detail. + /// + public partial class ErrorDetail + { + /// + /// Initializes a new instance of the ErrorDetail class. + /// + public ErrorDetail() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorDetail class. + /// + + /// The error code. + /// + + /// The error message. + /// + + /// The error target. + /// + + /// The error details. + /// + + /// The error additional info. + /// + public ErrorDetail(string code = default(string), string message = default(string), string target = default(string), System.Collections.Generic.IList details = default(System.Collections.Generic.IList), System.Collections.Generic.IList additionalInfo = default(System.Collections.Generic.IList)) + + { + this.Code = code; + this.Message = message; + this.Target = target; + this.Details = details; + this.AdditionalInfo = additionalInfo; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets the error code. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "code")] + public string Code {get; private set; } + + /// + /// Gets the error message. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "message")] + public string Message {get; private set; } + + /// + /// Gets the error target. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "target")] + public string Target {get; private set; } + + /// + /// Gets the error details. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "details")] + public System.Collections.Generic.IList Details {get; private set; } + + /// + /// Gets the error additional info. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "additionalInfo")] + public System.Collections.Generic.IList AdditionalInfo {get; private set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ErrorResponse.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ErrorResponse.cs new file mode 100644 index 000000000000..f1f9c9039a1c --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ErrorResponse.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// Common error response for all Azure Resource Manager APIs to return error + /// details for failed operations. (This also follows the OData error response + /// format.). + /// + /// + /// Common error response for all Azure Resource Manager APIs to return error + /// details for failed operations. (This also follows the OData error response + /// format.). + /// + public partial class ErrorResponse + { + /// + /// Initializes a new instance of the ErrorResponse class. + /// + public ErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + + /// The error object. + /// + public ErrorResponse(ErrorDetail error = default(ErrorDetail)) + + { + this.Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets the error object. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "error")] + public ErrorDetail Error {get; set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ErrorResponseException.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ErrorResponseException.cs new file mode 100644 index 000000000000..0d4b1762ee9b --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ErrorResponseException.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + + /// + /// Exception thrown for an invalid response with ErrorResponse information. + /// + public partial class ErrorResponseException : Microsoft.Rest.RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public Microsoft.Rest.HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public Microsoft.Rest.HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public ErrorResponse Body { get; set; } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + public ErrorResponseException() + { + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + /// The exception message. + public ErrorResponseException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + /// The exception message. + /// Inner exception. + public ErrorResponseException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/Page.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/Page.cs new file mode 100644 index 000000000000..09420b5d6992 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/Page.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [Newtonsoft.Json.JsonObject] + public class Page : Microsoft.Rest.Azure.IPage + { + /// + /// Gets the link to the next page. + /// + [Newtonsoft.Json.JsonProperty("nextLink")] + public System.String NextPageLink { get; private set; } + + [Newtonsoft.Json.JsonProperty("value")] + private System.Collections.Generic.IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public System.Collections.Generic.IEnumerator GetEnumerator() + { + return (Items == null) ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ProxyResource.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ProxyResource.cs new file mode 100644 index 000000000000..25bbebf0f423 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/ProxyResource.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// ARM proxy resource. + /// + public partial class ProxyResource : Resource + { + /// + /// Initializes a new instance of the ProxyResource class. + /// + public ProxyResource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ProxyResource class. + /// + + /// Resource ID. + /// + + /// Resource name. + /// + + /// Resource type. + /// + public ProxyResource(string id = default(string), string name = default(string), string type = default(string)) + + : base(id, name, type) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/Resource.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/Resource.cs new file mode 100644 index 000000000000..ff157f41e29e --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/Resource.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// ARM resource. + /// + public partial class Resource : Microsoft.Rest.Azure.IResource + { + /// + /// Initializes a new instance of the Resource class. + /// + public Resource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Resource class. + /// + + /// Resource ID. + /// + + /// Resource name. + /// + + /// Resource type. + /// + public Resource(string id = default(string), string name = default(string), string type = default(string)) + + { + this.Id = id; + this.Name = name; + this.Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets resource ID. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "id")] + public string Id {get; private set; } + + /// + /// Gets resource name. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "name")] + public string Name {get; private set; } + + /// + /// Gets resource type. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "type")] + public string Type {get; private set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/Sku.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/Sku.cs new file mode 100644 index 000000000000..70728b748a52 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/Sku.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// An ARM Resource SKU. + /// + public partial class Sku + { + /// + /// Initializes a new instance of the Sku class. + /// + public Sku() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Sku class. + /// + + /// The name of the SKU, typically, a letter + Number code, e.g. P3. + /// + + /// The tier or edition of the particular SKU, e.g. Basic, Premium. + /// + + /// Size of the particular SKU + /// + + /// If the service has different generations of hardware, for the same SKU, + /// then that can be captured here. + /// + + /// Capacity of the particular SKU. + /// + public Sku(string name, string tier = default(string), string size = default(string), string family = default(string), int? capacity = default(int?)) + + { + this.Name = name; + this.Tier = tier; + this.Size = size; + this.Family = family; + this.Capacity = capacity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets the name of the SKU, typically, a letter + Number code, e.g. + /// P3. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "name")] + public string Name {get; set; } + + /// + /// Gets or sets the tier or edition of the particular SKU, e.g. Basic, + /// Premium. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "tier")] + public string Tier {get; set; } + + /// + /// Gets or sets size of the particular SKU + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "size")] + public string Size {get; set; } + + /// + /// Gets or sets if the service has different generations of hardware, for the + /// same SKU, then that can be captured here. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "family")] + public string Family {get; set; } + + /// + /// Gets or sets capacity of the particular SKU. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "capacity")] + public int? Capacity {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (this.Name == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Name"); + } + + + + + } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncConflictResolutionPolicy.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncConflictResolutionPolicy.cs new file mode 100644 index 000000000000..f2b2bbc456c4 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncConflictResolutionPolicy.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + + /// + /// Defines values for SyncConflictResolutionPolicy. + /// + + + public static class SyncConflictResolutionPolicy + { + public const string HubWin = "HubWin"; + public const string MemberWin = "MemberWin"; + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncDatabaseIdProperties.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncDatabaseIdProperties.cs new file mode 100644 index 000000000000..a275d15c852d --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncDatabaseIdProperties.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// Properties of the sync database id. + /// + public partial class SyncDatabaseIdProperties + { + /// + /// Initializes a new instance of the SyncDatabaseIdProperties class. + /// + public SyncDatabaseIdProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncDatabaseIdProperties class. + /// + + /// ARM resource id of sync database. + /// + public SyncDatabaseIdProperties(string id = default(string)) + + { + this.Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets aRM resource id of sync database. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "id")] + public string Id {get; private set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncDirection.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncDirection.cs new file mode 100644 index 000000000000..87249d181e8b --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncDirection.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + + /// + /// Defines values for SyncDirection. + /// + + + public static class SyncDirection + { + public const string Bidirectional = "Bidirectional"; + public const string OneWayMemberToHub = "OneWayMemberToHub"; + public const string OneWayHubToMember = "OneWayHubToMember"; + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncFullSchemaProperties.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncFullSchemaProperties.cs new file mode 100644 index 000000000000..7226c9e534f9 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncFullSchemaProperties.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// Properties of the database full schema. + /// + public partial class SyncFullSchemaProperties + { + /// + /// Initializes a new instance of the SyncFullSchemaProperties class. + /// + public SyncFullSchemaProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncFullSchemaProperties class. + /// + + /// List of tables in the database full schema. + /// + + /// Last update time of the database schema. + /// + public SyncFullSchemaProperties(System.Collections.Generic.IList tables = default(System.Collections.Generic.IList), System.DateTime? lastUpdateTime = default(System.DateTime?)) + + { + this.Tables = tables; + this.LastUpdateTime = lastUpdateTime; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets list of tables in the database full schema. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "tables")] + public System.Collections.Generic.IList Tables {get; private set; } + + /// + /// Gets last update time of the database schema. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "lastUpdateTime")] + public System.DateTime? LastUpdateTime {get; private set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncFullSchemaTable.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncFullSchemaTable.cs new file mode 100644 index 000000000000..67f6c9e2f6a8 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncFullSchemaTable.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// Properties of the table in the database full schema. + /// + public partial class SyncFullSchemaTable + { + /// + /// Initializes a new instance of the SyncFullSchemaTable class. + /// + public SyncFullSchemaTable() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncFullSchemaTable class. + /// + + /// List of columns in the table of database full schema. + /// + + /// Error id of the table. + /// + + /// If there is error in the table. + /// + + /// Name of the table. + /// + + /// Quoted name of the table. + /// + public SyncFullSchemaTable(System.Collections.Generic.IList columns = default(System.Collections.Generic.IList), string errorId = default(string), bool? hasError = default(bool?), string name = default(string), string quotedName = default(string)) + + { + this.Columns = columns; + this.ErrorId = errorId; + this.HasError = hasError; + this.Name = name; + this.QuotedName = quotedName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets list of columns in the table of database full schema. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "columns")] + public System.Collections.Generic.IList Columns {get; private set; } + + /// + /// Gets error id of the table. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "errorId")] + public string ErrorId {get; private set; } + + /// + /// Gets if there is error in the table. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "hasError")] + public bool? HasError {get; private set; } + + /// + /// Gets name of the table. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "name")] + public string Name {get; private set; } + + /// + /// Gets quoted name of the table. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "quotedName")] + public string QuotedName {get; private set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncFullSchemaTableColumn.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncFullSchemaTableColumn.cs new file mode 100644 index 000000000000..4d82f96c2efa --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncFullSchemaTableColumn.cs @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// Properties of the column in the table of database full schema. + /// + public partial class SyncFullSchemaTableColumn + { + /// + /// Initializes a new instance of the SyncFullSchemaTableColumn class. + /// + public SyncFullSchemaTableColumn() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncFullSchemaTableColumn class. + /// + + /// Data size of the column. + /// + + /// Data type of the column. + /// + + /// Error id of the column. + /// + + /// If there is error in the table. + /// + + /// If it is the primary key of the table. + /// + + /// Name of the column. + /// + + /// Quoted name of the column. + /// + public SyncFullSchemaTableColumn(string dataSize = default(string), string dataType = default(string), string errorId = default(string), bool? hasError = default(bool?), bool? isPrimaryKey = default(bool?), string name = default(string), string quotedName = default(string)) + + { + this.DataSize = dataSize; + this.DataType = dataType; + this.ErrorId = errorId; + this.HasError = hasError; + this.IsPrimaryKey = isPrimaryKey; + this.Name = name; + this.QuotedName = quotedName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets data size of the column. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "dataSize")] + public string DataSize {get; private set; } + + /// + /// Gets data type of the column. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "dataType")] + public string DataType {get; private set; } + + /// + /// Gets error id of the column. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "errorId")] + public string ErrorId {get; private set; } + + /// + /// Gets if there is error in the table. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "hasError")] + public bool? HasError {get; private set; } + + /// + /// Gets if it is the primary key of the table. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "isPrimaryKey")] + public bool? IsPrimaryKey {get; private set; } + + /// + /// Gets name of the column. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "name")] + public string Name {get; private set; } + + /// + /// Gets quoted name of the column. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "quotedName")] + public string QuotedName {get; private set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroup.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroup.cs new file mode 100644 index 000000000000..556abd1d14f3 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroup.cs @@ -0,0 +1,220 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// An Azure SQL Database sync group. + /// + [Microsoft.Rest.Serialization.JsonTransformation] + public partial class SyncGroup : ProxyResource + { + /// + /// Initializes a new instance of the SyncGroup class. + /// + public SyncGroup() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncGroup class. + /// + + /// Resource ID. + /// + + /// Resource name. + /// + + /// Resource type. + /// + + /// The name and capacity of the SKU. + /// + + /// Sync group authentication information. + /// + + /// Sync interval of the sync group. + /// + + /// Last sync time of the sync group. + /// + + /// Conflict resolution policy of the sync group. + /// Possible values include: 'HubWin', 'MemberWin' + + /// ARM resource id of the sync database in the sync group. + /// + + /// User name for the sync group hub database credential. + /// + + /// Password for the sync group hub database credential. + /// + + /// Sync state of the sync group. + /// Possible values include: 'NotReady', 'Error', 'Warning', 'Progressing', + /// 'Good' + + /// Sync schema of the sync group. + /// + + /// If conflict logging is enabled. + /// + + /// Conflict logging retention period. + /// + + /// If use private link connection is enabled. + /// + + /// Private endpoint name of the sync group if use private link connection is + /// enabled. + /// + public SyncGroup(DataSyncParticipantIdentity identity, string id = default(string), string name = default(string), string type = default(string), Sku sku = default(Sku), int? interval = default(int?), System.DateTime? lastSyncTime = default(System.DateTime?), string conflictResolutionPolicy = default(string), string syncDatabaseId = default(string), string hubDatabaseUserName = default(string), string hubDatabasePassword = default(string), string syncState = default(string), SyncGroupSchema schema = default(SyncGroupSchema), bool? enableConflictLogging = default(bool?), int? conflictLoggingRetentionInDays = default(int?), bool? usePrivateLinkConnection = default(bool?), string privateEndpointName = default(string)) + + : base(id, name, type) + { + this.Sku = sku; + this.Identity = identity; + this.Interval = interval; + this.LastSyncTime = lastSyncTime; + this.ConflictResolutionPolicy = conflictResolutionPolicy; + this.SyncDatabaseId = syncDatabaseId; + this.HubDatabaseUserName = hubDatabaseUserName; + this.HubDatabasePassword = hubDatabasePassword; + this.SyncState = syncState; + this.Schema = schema; + this.EnableConflictLogging = enableConflictLogging; + this.ConflictLoggingRetentionInDays = conflictLoggingRetentionInDays; + this.UsePrivateLinkConnection = usePrivateLinkConnection; + this.PrivateEndpointName = privateEndpointName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets the name and capacity of the SKU. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "sku")] + public Sku Sku {get; set; } + + /// + /// Gets or sets sync group authentication information. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "identity")] + public DataSyncParticipantIdentity Identity {get; set; } + + /// + /// Gets or sets sync interval of the sync group. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.interval")] + public int? Interval {get; set; } + + /// + /// Gets last sync time of the sync group. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.lastSyncTime")] + public System.DateTime? LastSyncTime {get; private set; } + + /// + /// Gets or sets conflict resolution policy of the sync group. Possible values include: 'HubWin', 'MemberWin' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.conflictResolutionPolicy")] + public string ConflictResolutionPolicy {get; set; } + + /// + /// Gets or sets aRM resource id of the sync database in the sync group. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.syncDatabaseId")] + public string SyncDatabaseId {get; set; } + + /// + /// Gets or sets user name for the sync group hub database credential. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.hubDatabaseUserName")] + public string HubDatabaseUserName {get; set; } + + /// + /// Gets or sets password for the sync group hub database credential. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.hubDatabasePassword")] + public string HubDatabasePassword {get; set; } + + /// + /// Gets sync state of the sync group. Possible values include: 'NotReady', 'Error', 'Warning', 'Progressing', 'Good' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.syncState")] + public string SyncState {get; private set; } + + /// + /// Gets or sets sync schema of the sync group. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.schema")] + public SyncGroupSchema Schema {get; set; } + + /// + /// Gets or sets if conflict logging is enabled. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.enableConflictLogging")] + public bool? EnableConflictLogging {get; set; } + + /// + /// Gets or sets conflict logging retention period. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.conflictLoggingRetentionInDays")] + public int? ConflictLoggingRetentionInDays {get; set; } + + /// + /// Gets or sets if use private link connection is enabled. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.usePrivateLinkConnection")] + public bool? UsePrivateLinkConnection {get; set; } + + /// + /// Gets private endpoint name of the sync group if use private link connection + /// is enabled. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.privateEndpointName")] + public string PrivateEndpointName {get; private set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (this.Identity == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Identity"); + } + if (this.Sku != null) + { + this.Sku.Validate(); + } + if (this.Identity != null) + { + this.Identity.Validate(); + } + + + + + + + + } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupLogProperties.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupLogProperties.cs new file mode 100644 index 000000000000..54c5be04619c --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupLogProperties.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// Properties of an Azure SQL Database sync group log. + /// + public partial class SyncGroupLogProperties + { + /// + /// Initializes a new instance of the SyncGroupLogProperties class. + /// + public SyncGroupLogProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncGroupLogProperties class. + /// + + /// Timestamp of the sync group log. + /// + + /// Type of the sync group log. + /// Possible values include: 'All', 'Error', 'Warning', 'Success' + + /// Source of the sync group log. + /// + + /// Details of the sync group log. + /// + + /// TracingId of the sync group log. + /// + + /// OperationStatus of the sync group log. + /// + public SyncGroupLogProperties(System.DateTime? timestamp = default(System.DateTime?), string type = default(string), string source = default(string), string details = default(string), System.Guid? tracingId = default(System.Guid?), string operationStatus = default(string)) + + { + this.Timestamp = timestamp; + this.Type = type; + this.Source = source; + this.Details = details; + this.TracingId = tracingId; + this.OperationStatus = operationStatus; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets timestamp of the sync group log. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "timestamp")] + public System.DateTime? Timestamp {get; private set; } + + /// + /// Gets type of the sync group log. Possible values include: 'All', 'Error', 'Warning', 'Success' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "type")] + public string Type {get; private set; } + + /// + /// Gets source of the sync group log. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "source")] + public string Source {get; private set; } + + /// + /// Gets details of the sync group log. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "details")] + public string Details {get; private set; } + + /// + /// Gets tracingId of the sync group log. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "tracingId")] + public System.Guid? TracingId {get; private set; } + + /// + /// Gets operationStatus of the sync group log. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "operationStatus")] + public string OperationStatus {get; private set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupLogType.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupLogType.cs new file mode 100644 index 000000000000..6b92cb21fd5c --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupLogType.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + + /// + /// Defines values for SyncGroupLogType. + /// + + + public static class SyncGroupLogType + { + public const string All = "All"; + public const string Error = "Error"; + public const string Warning = "Warning"; + public const string Success = "Success"; + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupProperties.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupProperties.cs new file mode 100644 index 000000000000..e3c123893280 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupProperties.cs @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// Properties of a sync group with support to MI. + /// + public partial class SyncGroupProperties + { + /// + /// Initializes a new instance of the SyncGroupProperties class. + /// + public SyncGroupProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncGroupProperties class. + /// + + /// Sync interval of the sync group. + /// + + /// Last sync time of the sync group. + /// + + /// Conflict resolution policy of the sync group. + /// Possible values include: 'HubWin', 'MemberWin' + + /// ARM resource id of the sync database in the sync group. + /// + + /// User name for the sync group hub database credential. + /// + + /// Password for the sync group hub database credential. + /// + + /// Sync state of the sync group. + /// Possible values include: 'NotReady', 'Error', 'Warning', 'Progressing', + /// 'Good' + + /// Sync schema of the sync group. + /// + + /// If conflict logging is enabled. + /// + + /// Conflict logging retention period. + /// + + /// If use private link connection is enabled. + /// + + /// Private endpoint name of the sync group if use private link connection is + /// enabled. + /// + public SyncGroupProperties(int? interval = default(int?), System.DateTime? lastSyncTime = default(System.DateTime?), string conflictResolutionPolicy = default(string), string syncDatabaseId = default(string), string hubDatabaseUserName = default(string), string hubDatabasePassword = default(string), string syncState = default(string), SyncGroupSchema schema = default(SyncGroupSchema), bool? enableConflictLogging = default(bool?), int? conflictLoggingRetentionInDays = default(int?), bool? usePrivateLinkConnection = default(bool?), string privateEndpointName = default(string)) + + { + this.Interval = interval; + this.LastSyncTime = lastSyncTime; + this.ConflictResolutionPolicy = conflictResolutionPolicy; + this.SyncDatabaseId = syncDatabaseId; + this.HubDatabaseUserName = hubDatabaseUserName; + this.HubDatabasePassword = hubDatabasePassword; + this.SyncState = syncState; + this.Schema = schema; + this.EnableConflictLogging = enableConflictLogging; + this.ConflictLoggingRetentionInDays = conflictLoggingRetentionInDays; + this.UsePrivateLinkConnection = usePrivateLinkConnection; + this.PrivateEndpointName = privateEndpointName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets sync interval of the sync group. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "interval")] + public int? Interval {get; set; } + + /// + /// Gets last sync time of the sync group. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "lastSyncTime")] + public System.DateTime? LastSyncTime {get; private set; } + + /// + /// Gets or sets conflict resolution policy of the sync group. Possible values include: 'HubWin', 'MemberWin' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "conflictResolutionPolicy")] + public string ConflictResolutionPolicy {get; set; } + + /// + /// Gets or sets aRM resource id of the sync database in the sync group. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "syncDatabaseId")] + public string SyncDatabaseId {get; set; } + + /// + /// Gets or sets user name for the sync group hub database credential. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "hubDatabaseUserName")] + public string HubDatabaseUserName {get; set; } + + /// + /// Gets or sets password for the sync group hub database credential. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "hubDatabasePassword")] + public string HubDatabasePassword {get; set; } + + /// + /// Gets sync state of the sync group. Possible values include: 'NotReady', 'Error', 'Warning', 'Progressing', 'Good' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "syncState")] + public string SyncState {get; private set; } + + /// + /// Gets or sets sync schema of the sync group. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "schema")] + public SyncGroupSchema Schema {get; set; } + + /// + /// Gets or sets if conflict logging is enabled. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "enableConflictLogging")] + public bool? EnableConflictLogging {get; set; } + + /// + /// Gets or sets conflict logging retention period. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "conflictLoggingRetentionInDays")] + public int? ConflictLoggingRetentionInDays {get; set; } + + /// + /// Gets or sets if use private link connection is enabled. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "usePrivateLinkConnection")] + public bool? UsePrivateLinkConnection {get; set; } + + /// + /// Gets private endpoint name of the sync group if use private link connection + /// is enabled. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "privateEndpointName")] + public string PrivateEndpointName {get; private set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupSchema.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupSchema.cs new file mode 100644 index 000000000000..6c8eee39d9f5 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupSchema.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// Properties of sync group schema. + /// + public partial class SyncGroupSchema + { + /// + /// Initializes a new instance of the SyncGroupSchema class. + /// + public SyncGroupSchema() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncGroupSchema class. + /// + + /// List of tables in sync group schema. + /// + + /// Name of master sync member where the schema is from. + /// + public SyncGroupSchema(System.Collections.Generic.IList tables = default(System.Collections.Generic.IList), string masterSyncMemberName = default(string)) + + { + this.Tables = tables; + this.MasterSyncMemberName = masterSyncMemberName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets list of tables in sync group schema. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "tables")] + public System.Collections.Generic.IList Tables {get; set; } + + /// + /// Gets or sets name of master sync member where the schema is from. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "masterSyncMemberName")] + public string MasterSyncMemberName {get; set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupSchemaTable.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupSchemaTable.cs new file mode 100644 index 000000000000..8f66b422b5f3 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupSchemaTable.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// Properties of table in sync group schema. + /// + public partial class SyncGroupSchemaTable + { + /// + /// Initializes a new instance of the SyncGroupSchemaTable class. + /// + public SyncGroupSchemaTable() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncGroupSchemaTable class. + /// + + /// List of columns in sync group schema. + /// + + /// Quoted name of sync group schema table. + /// + public SyncGroupSchemaTable(System.Collections.Generic.IList columns = default(System.Collections.Generic.IList), string quotedName = default(string)) + + { + this.Columns = columns; + this.QuotedName = quotedName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets list of columns in sync group schema. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "columns")] + public System.Collections.Generic.IList Columns {get; set; } + + /// + /// Gets or sets quoted name of sync group schema table. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "quotedName")] + public string QuotedName {get; set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupSchemaTableColumn.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupSchemaTableColumn.cs new file mode 100644 index 000000000000..818941621f54 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupSchemaTableColumn.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// Properties of column in sync group table. + /// + public partial class SyncGroupSchemaTableColumn + { + /// + /// Initializes a new instance of the SyncGroupSchemaTableColumn class. + /// + public SyncGroupSchemaTableColumn() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncGroupSchemaTableColumn class. + /// + + /// Quoted name of sync group table column. + /// + + /// Data size of the column. + /// + + /// Data type of the column. + /// + public SyncGroupSchemaTableColumn(string quotedName = default(string), string dataSize = default(string), string dataType = default(string)) + + { + this.QuotedName = quotedName; + this.DataSize = dataSize; + this.DataType = dataType; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets quoted name of sync group table column. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "quotedName")] + public string QuotedName {get; set; } + + /// + /// Gets or sets data size of the column. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "dataSize")] + public string DataSize {get; set; } + + /// + /// Gets or sets data type of the column. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "dataType")] + public string DataType {get; set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupState.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupState.cs new file mode 100644 index 000000000000..87f84cf48075 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupState.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + + /// + /// Defines values for SyncGroupState. + /// + + + public static class SyncGroupState + { + public const string NotReady = "NotReady"; + public const string Error = "Error"; + public const string Warning = "Warning"; + public const string Progressing = "Progressing"; + public const string Good = "Good"; + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsCreateOrUpdateHeaders.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsCreateOrUpdateHeaders.cs new file mode 100644 index 000000000000..bc4d1c410a02 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsCreateOrUpdateHeaders.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + public partial class SyncGroupsCreateOrUpdateHeaders + { + /// + /// Initializes a new instance of the SyncGroupsCreateOrUpdateHeaders class. + /// + public SyncGroupsCreateOrUpdateHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncGroupsCreateOrUpdateHeaders class. + /// + + /// + /// + public SyncGroupsCreateOrUpdateHeaders(string location = default(string)) + + { + this.Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "Location")] + public string Location {get; set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsDeleteHeaders.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsDeleteHeaders.cs new file mode 100644 index 000000000000..aaa7aa24628c --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsDeleteHeaders.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + public partial class SyncGroupsDeleteHeaders + { + /// + /// Initializes a new instance of the SyncGroupsDeleteHeaders class. + /// + public SyncGroupsDeleteHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncGroupsDeleteHeaders class. + /// + + /// + /// + public SyncGroupsDeleteHeaders(string location = default(string)) + + { + this.Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "Location")] + public string Location {get; set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsRefreshHubSchemaHeaders.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsRefreshHubSchemaHeaders.cs new file mode 100644 index 000000000000..4a001a288562 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsRefreshHubSchemaHeaders.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + public partial class SyncGroupsRefreshHubSchemaHeaders + { + /// + /// Initializes a new instance of the SyncGroupsRefreshHubSchemaHeaders class. + /// + public SyncGroupsRefreshHubSchemaHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncGroupsRefreshHubSchemaHeaders class. + /// + + /// + /// + public SyncGroupsRefreshHubSchemaHeaders(string location = default(string)) + + { + this.Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "Location")] + public string Location {get; set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsType.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsType.cs new file mode 100644 index 000000000000..bb5a53328721 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsType.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + + /// + /// Defines values for SyncGroupsType. + /// + + + public static class SyncGroupsType + { + public const string All = "All"; + public const string Error = "Error"; + public const string Warning = "Warning"; + public const string Success = "Success"; + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsUpdateHeaders.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsUpdateHeaders.cs new file mode 100644 index 000000000000..2af357ce20c5 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncGroupsUpdateHeaders.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + public partial class SyncGroupsUpdateHeaders + { + /// + /// Initializes a new instance of the SyncGroupsUpdateHeaders class. + /// + public SyncGroupsUpdateHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncGroupsUpdateHeaders class. + /// + + /// + /// + public SyncGroupsUpdateHeaders(string location = default(string)) + + { + this.Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "Location")] + public string Location {get; set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMember.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMember.cs new file mode 100644 index 000000000000..b964ab9bb963 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMember.cs @@ -0,0 +1,216 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// An Azure SQL Database sync member. + /// + [Microsoft.Rest.Serialization.JsonTransformation] + public partial class SyncMember : ProxyResource + { + /// + /// Initializes a new instance of the SyncMember class. + /// + public SyncMember() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncMember class. + /// + + /// Resource ID. + /// + + /// Resource name. + /// + + /// Resource type. + /// + + /// Sync member authentication information. + /// + + /// Sync direction of the sync member. + /// Possible values include: 'Bidirectional', 'OneWayMemberToHub', + /// 'OneWayHubToMember' + + /// Database type of the sync member. + /// Possible values include: 'AzureSqlDatabase', 'SqlServerDatabase' + + /// ARM resource id of the sync agent in the sync member. + /// + + /// SQL Server database id of the sync member. + /// + + /// ARM resource id of the sync member logical database, for sync members in + /// Azure. + /// + + /// Whether to use private link connection. + /// + + /// Private endpoint name of the sync member if use private link connection is + /// enabled, for sync members in Azure. + /// + + /// Server name of the member database in the sync member + /// + + /// Database name of the member database in the sync member. + /// + + /// User name of the member database in the sync member. + /// + + /// Password of the member database in the sync member. + /// + + /// Sync state of the sync member. + /// Possible values include: 'SyncInProgress', 'SyncSucceeded', 'SyncFailed', + /// 'DisabledTombstoneCleanup', 'DisabledBackupRestore', + /// 'SyncSucceededWithWarnings', 'SyncCancelling', 'SyncCancelled', + /// 'UnProvisioned', 'Provisioning', 'Provisioned', 'ProvisionFailed', + /// 'DeProvisioning', 'DeProvisioned', 'DeProvisionFailed', 'Reprovisioning', + /// 'ReprovisionFailed', 'UnReprovisioned' + public SyncMember(DataSyncParticipantIdentity identity, string id = default(string), string name = default(string), string type = default(string), string syncDirection = default(string), string databaseType = default(string), string syncAgentId = default(string), System.Guid? sqlServerDatabaseId = default(System.Guid?), string syncMemberAzureDatabaseResourceId = default(string), bool? usePrivateLinkConnection = default(bool?), string privateEndpointName = default(string), string serverName = default(string), string databaseName = default(string), string userName = default(string), string password = default(string), string syncState = default(string)) + + : base(id, name, type) + { + this.Identity = identity; + this.SyncDirection = syncDirection; + this.DatabaseType = databaseType; + this.SyncAgentId = syncAgentId; + this.SqlServerDatabaseId = sqlServerDatabaseId; + this.SyncMemberAzureDatabaseResourceId = syncMemberAzureDatabaseResourceId; + this.UsePrivateLinkConnection = usePrivateLinkConnection; + this.PrivateEndpointName = privateEndpointName; + this.ServerName = serverName; + this.DatabaseName = databaseName; + this.UserName = userName; + this.Password = password; + this.SyncState = syncState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets sync member authentication information. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "identity")] + public DataSyncParticipantIdentity Identity {get; set; } + + /// + /// Gets or sets sync direction of the sync member. Possible values include: 'Bidirectional', 'OneWayMemberToHub', 'OneWayHubToMember' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.syncDirection")] + public string SyncDirection {get; set; } + + /// + /// Gets or sets database type of the sync member. Possible values include: 'AzureSqlDatabase', 'SqlServerDatabase' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.databaseType")] + public string DatabaseType {get; set; } + + /// + /// Gets or sets aRM resource id of the sync agent in the sync member. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.syncAgentId")] + public string SyncAgentId {get; set; } + + /// + /// Gets or sets sQL Server database id of the sync member. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.sqlServerDatabaseId")] + public System.Guid? SqlServerDatabaseId {get; set; } + + /// + /// Gets or sets aRM resource id of the sync member logical database, for sync + /// members in Azure. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.syncMemberAzureDatabaseResourceId")] + public string SyncMemberAzureDatabaseResourceId {get; set; } + + /// + /// Gets or sets whether to use private link connection. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.usePrivateLinkConnection")] + public bool? UsePrivateLinkConnection {get; set; } + + /// + /// Gets private endpoint name of the sync member if use private link + /// connection is enabled, for sync members in Azure. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.privateEndpointName")] + public string PrivateEndpointName {get; private set; } + + /// + /// Gets or sets server name of the member database in the sync member + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.serverName")] + public string ServerName {get; set; } + + /// + /// Gets or sets database name of the member database in the sync member. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.databaseName")] + public string DatabaseName {get; set; } + + /// + /// Gets or sets user name of the member database in the sync member. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.userName")] + public string UserName {get; set; } + + /// + /// Gets or sets password of the member database in the sync member. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.password")] + public string Password {get; set; } + + /// + /// Gets sync state of the sync member. Possible values include: 'SyncInProgress', 'SyncSucceeded', 'SyncFailed', 'DisabledTombstoneCleanup', 'DisabledBackupRestore', 'SyncSucceededWithWarnings', 'SyncCancelling', 'SyncCancelled', 'UnProvisioned', 'Provisioning', 'Provisioned', 'ProvisionFailed', 'DeProvisioning', 'DeProvisioned', 'DeProvisionFailed', 'Reprovisioning', 'ReprovisionFailed', 'UnReprovisioned' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "properties.syncState")] + public string SyncState {get; private set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (this.Identity == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Identity"); + } + if (this.Identity != null) + { + this.Identity.Validate(); + } + + + + + + + + + + + } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMemberDbType.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMemberDbType.cs new file mode 100644 index 000000000000..a2ed245e8ff0 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMemberDbType.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + + /// + /// Defines values for SyncMemberDbType. + /// + + + public static class SyncMemberDbType + { + public const string AzureSqlDatabase = "AzureSqlDatabase"; + public const string SqlServerDatabase = "SqlServerDatabase"; + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMemberProperties.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMemberProperties.cs new file mode 100644 index 000000000000..3dd7a9cf72e6 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMemberProperties.cs @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + /// + /// Properties of a sync member with support to MI. + /// + public partial class SyncMemberProperties + { + /// + /// Initializes a new instance of the SyncMemberProperties class. + /// + public SyncMemberProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncMemberProperties class. + /// + + /// Database type of the sync member. + /// Possible values include: 'AzureSqlDatabase', 'SqlServerDatabase' + + /// ARM resource id of the sync agent in the sync member. + /// + + /// SQL Server database id of the sync member. + /// + + /// ARM resource id of the sync member logical database, for sync members in + /// Azure. + /// + + /// Whether to use private link connection. + /// + + /// Private endpoint name of the sync member if use private link connection is + /// enabled, for sync members in Azure. + /// + + /// Server name of the member database in the sync member + /// + + /// Database name of the member database in the sync member. + /// + + /// User name of the member database in the sync member. + /// + + /// Password of the member database in the sync member. + /// + + /// Sync direction of the sync member. + /// Possible values include: 'Bidirectional', 'OneWayMemberToHub', + /// 'OneWayHubToMember' + + /// Sync state of the sync member. + /// Possible values include: 'SyncInProgress', 'SyncSucceeded', 'SyncFailed', + /// 'DisabledTombstoneCleanup', 'DisabledBackupRestore', + /// 'SyncSucceededWithWarnings', 'SyncCancelling', 'SyncCancelled', + /// 'UnProvisioned', 'Provisioning', 'Provisioned', 'ProvisionFailed', + /// 'DeProvisioning', 'DeProvisioned', 'DeProvisionFailed', 'Reprovisioning', + /// 'ReprovisionFailed', 'UnReprovisioned' + public SyncMemberProperties(string databaseType = default(string), string syncAgentId = default(string), System.Guid? sqlServerDatabaseId = default(System.Guid?), string syncMemberAzureDatabaseResourceId = default(string), bool? usePrivateLinkConnection = default(bool?), string privateEndpointName = default(string), string serverName = default(string), string databaseName = default(string), string userName = default(string), string password = default(string), string syncDirection = default(string), string syncState = default(string)) + + { + this.DatabaseType = databaseType; + this.SyncAgentId = syncAgentId; + this.SqlServerDatabaseId = sqlServerDatabaseId; + this.SyncMemberAzureDatabaseResourceId = syncMemberAzureDatabaseResourceId; + this.UsePrivateLinkConnection = usePrivateLinkConnection; + this.PrivateEndpointName = privateEndpointName; + this.ServerName = serverName; + this.DatabaseName = databaseName; + this.UserName = userName; + this.Password = password; + this.SyncDirection = syncDirection; + this.SyncState = syncState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets database type of the sync member. Possible values include: 'AzureSqlDatabase', 'SqlServerDatabase' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "databaseType")] + public string DatabaseType {get; set; } + + /// + /// Gets or sets aRM resource id of the sync agent in the sync member. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "syncAgentId")] + public string SyncAgentId {get; set; } + + /// + /// Gets or sets sQL Server database id of the sync member. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "sqlServerDatabaseId")] + public System.Guid? SqlServerDatabaseId {get; set; } + + /// + /// Gets or sets aRM resource id of the sync member logical database, for sync + /// members in Azure. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "syncMemberAzureDatabaseResourceId")] + public string SyncMemberAzureDatabaseResourceId {get; set; } + + /// + /// Gets or sets whether to use private link connection. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "usePrivateLinkConnection")] + public bool? UsePrivateLinkConnection {get; set; } + + /// + /// Gets private endpoint name of the sync member if use private link + /// connection is enabled, for sync members in Azure. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "privateEndpointName")] + public string PrivateEndpointName {get; private set; } + + /// + /// Gets or sets server name of the member database in the sync member + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "serverName")] + public string ServerName {get; set; } + + /// + /// Gets or sets database name of the member database in the sync member. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "databaseName")] + public string DatabaseName {get; set; } + + /// + /// Gets or sets user name of the member database in the sync member. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "userName")] + public string UserName {get; set; } + + /// + /// Gets or sets password of the member database in the sync member. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "password")] + public string Password {get; set; } + + /// + /// Gets or sets sync direction of the sync member. Possible values include: 'Bidirectional', 'OneWayMemberToHub', 'OneWayHubToMember' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "syncDirection")] + public string SyncDirection {get; set; } + + /// + /// Gets sync state of the sync member. Possible values include: 'SyncInProgress', 'SyncSucceeded', 'SyncFailed', 'DisabledTombstoneCleanup', 'DisabledBackupRestore', 'SyncSucceededWithWarnings', 'SyncCancelling', 'SyncCancelled', 'UnProvisioned', 'Provisioning', 'Provisioned', 'ProvisionFailed', 'DeProvisioning', 'DeProvisioned', 'DeProvisionFailed', 'Reprovisioning', 'ReprovisionFailed', 'UnReprovisioned' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "syncState")] + public string SyncState {get; private set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMemberState.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMemberState.cs new file mode 100644 index 000000000000..64e5a80cbfb0 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMemberState.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + + /// + /// Defines values for SyncMemberState. + /// + + + public static class SyncMemberState + { + public const string SyncInProgress = "SyncInProgress"; + public const string SyncSucceeded = "SyncSucceeded"; + public const string SyncFailed = "SyncFailed"; + public const string DisabledTombstoneCleanup = "DisabledTombstoneCleanup"; + public const string DisabledBackupRestore = "DisabledBackupRestore"; + public const string SyncSucceededWithWarnings = "SyncSucceededWithWarnings"; + public const string SyncCancelling = "SyncCancelling"; + public const string SyncCancelled = "SyncCancelled"; + public const string UnProvisioned = "UnProvisioned"; + public const string Provisioning = "Provisioning"; + public const string Provisioned = "Provisioned"; + public const string ProvisionFailed = "ProvisionFailed"; + public const string DeProvisioning = "DeProvisioning"; + public const string DeProvisioned = "DeProvisioned"; + public const string DeProvisionFailed = "DeProvisionFailed"; + public const string Reprovisioning = "Reprovisioning"; + public const string ReprovisionFailed = "ReprovisionFailed"; + public const string UnReprovisioned = "UnReprovisioned"; + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMembersCreateOrUpdateHeaders.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMembersCreateOrUpdateHeaders.cs new file mode 100644 index 000000000000..f567fe8e93d5 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMembersCreateOrUpdateHeaders.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + public partial class SyncMembersCreateOrUpdateHeaders + { + /// + /// Initializes a new instance of the SyncMembersCreateOrUpdateHeaders class. + /// + public SyncMembersCreateOrUpdateHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncMembersCreateOrUpdateHeaders class. + /// + + /// + /// + public SyncMembersCreateOrUpdateHeaders(string location = default(string)) + + { + this.Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "Location")] + public string Location {get; set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMembersDeleteHeaders.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMembersDeleteHeaders.cs new file mode 100644 index 000000000000..be9920fe06e7 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMembersDeleteHeaders.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + public partial class SyncMembersDeleteHeaders + { + /// + /// Initializes a new instance of the SyncMembersDeleteHeaders class. + /// + public SyncMembersDeleteHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncMembersDeleteHeaders class. + /// + + /// + /// + public SyncMembersDeleteHeaders(string location = default(string)) + + { + this.Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "Location")] + public string Location {get; set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMembersRefreshMemberSchemaHeaders.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMembersRefreshMemberSchemaHeaders.cs new file mode 100644 index 000000000000..da1001c7db0f --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMembersRefreshMemberSchemaHeaders.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + public partial class SyncMembersRefreshMemberSchemaHeaders + { + /// + /// Initializes a new instance of the SyncMembersRefreshMemberSchemaHeaders class. + /// + public SyncMembersRefreshMemberSchemaHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncMembersRefreshMemberSchemaHeaders class. + /// + + /// + /// + public SyncMembersRefreshMemberSchemaHeaders(string location = default(string)) + + { + this.Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "Location")] + public string Location {get; set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMembersUpdateHeaders.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMembersUpdateHeaders.cs new file mode 100644 index 000000000000..b8ec23ee50c4 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/Models/SyncMembersUpdateHeaders.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2.Models +{ + using System.Linq; + + public partial class SyncMembersUpdateHeaders + { + /// + /// Initializes a new instance of the SyncMembersUpdateHeaders class. + /// + public SyncMembersUpdateHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SyncMembersUpdateHeaders class. + /// + + /// + /// + public SyncMembersUpdateHeaders(string location = default(string)) + + { + this.Location = location; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "Location")] + public string Location {get; set; } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SqlManagementClient.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SqlManagementClient.cs new file mode 100644 index 000000000000..80aa043c9eab --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SqlManagementClient.cs @@ -0,0 +1,350 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2 +{ + using System.Linq; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// The Azure SQL Database management API provides a RESTful set of web APIs + /// that interact with Azure SQL Database services to manage your databases. + /// The API enables users to create, retrieve, update, and delete databases, + /// servers, and other entities. + /// + public partial class SqlManagementClient : Microsoft.Rest.ServiceClient, ISqlManagementClient, IAzureClient + { + /// + /// The base URI of the service. + /// + public System.Uri BaseUri { get; set; } + /// + /// Gets or sets json serialization settings. + /// + public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + /// + /// Gets or sets json deserialization settings. + /// + public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + /// + /// Credentials needed for the client to connect to Azure. + /// + public Microsoft.Rest.ServiceClientCredentials Credentials { get; private set; } + + /// + /// The API version to use for this operation. + /// + public string ApiVersion { get; private set; } + + /// + /// The subscription ID that identifies an Azure subscription. + /// + public string SubscriptionId { get; set;} + + /// + /// The preferred language for the response. + /// + public string AcceptLanguage { get; set;} + + /// + /// The retry timeout in seconds for Long Running Operations. Default + /// /// value is 30. + /// + public int? LongRunningOperationRetryTimeout { get; set;} + + /// + /// Whether a unique x-ms-client-request-id should be generated. When + /// /// set to true a unique x-ms-client-request-id value is generated and + /// /// included in each request. Default is true. + /// + public bool? GenerateClientRequestId { get; set;} + + /// + /// Gets the ISyncGroupsOperations + /// + public virtual ISyncGroupsOperations SyncGroups { get; private set; } + /// + /// Gets the ISyncMembersOperations + /// + public virtual ISyncMembersOperations SyncMembers { get; private set; } + /// + /// Initializes a new instance of the SqlManagementClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling SqlManagementClient.Dispose(). False: will not dispose provided httpClient + protected SqlManagementClient(System.Net.Http.HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + this.Initialize(); + } + /// + /// Initializes a new instance of the SqlManagementClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected SqlManagementClient(params System.Net.Http.DelegatingHandler[] handlers) : base(handlers) + { + this.Initialize(); + } + /// + /// Initializes a new instance of the SqlManagementClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected SqlManagementClient(System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + this.Initialize(); + } + /// + /// Initializes a new instance of the SqlManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected SqlManagementClient(System.Uri baseUri, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + /// + /// Initializes a new instance of the SqlManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected SqlManagementClient(System.Uri baseUri, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + + this.BaseUri = baseUri; + } + /// + /// Initializes a new instance of the SqlManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public SqlManagementClient(Microsoft.Rest.ServiceClientCredentials credentials, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + + } + /// + /// Initializes a new instance of the SqlManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling SqlManagementClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public SqlManagementClient(Microsoft.Rest.ServiceClientCredentials credentials, System.Net.Http.HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + + } + /// + /// Initializes a new instance of the SqlManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public SqlManagementClient(Microsoft.Rest.ServiceClientCredentials credentials, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + + } + /// + /// Initializes a new instance of the SqlManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public SqlManagementClient(System.Uri baseUri, Microsoft.Rest.ServiceClientCredentials credentials, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + this.BaseUri = baseUri; + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + + } + /// + /// Initializes a new instance of the SqlManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public SqlManagementClient(System.Uri baseUri, Microsoft.Rest.ServiceClientCredentials credentials, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + this.BaseUri = baseUri; + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + + } + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + + /// + /// Initializes client properties. + /// + private void Initialize() + { + this.SyncGroups = new SyncGroupsOperations(this); + this.SyncMembers = new SyncMembersOperations(this); + this.BaseUri = new System.Uri("https://management.azure.com"); + this.ApiVersion = "2025-02-01-preview"; + this.AcceptLanguage = "en-US"; + this.LongRunningOperationRetryTimeout = 30; + this.GenerateClientRequestId = true; + SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + { + Formatting = Newtonsoft.Json.Formatting.Indented, + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new Microsoft.Rest.Serialization.ReadOnlyJsonContractResolver(), + Converters = new System.Collections.Generic.List + { + new Microsoft.Rest.Serialization.Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new Microsoft.Rest.Serialization.TransformationJsonConverter()); + DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new Microsoft.Rest.Serialization.ReadOnlyJsonContractResolver(), + Converters = new System.Collections.Generic.List + { + new Microsoft.Rest.Serialization.Iso8601TimeSpanConverter() + } + }; + CustomInitialize(); + DeserializationSettings.Converters.Add(new Microsoft.Rest.Serialization.TransformationJsonConverter()); + DeserializationSettings.Converters.Add(new Microsoft.Rest.Azure.CloudErrorJsonConverter()); + } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SyncGroupsOperations.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SyncGroupsOperations.cs new file mode 100644 index 000000000000..802d93bd89e3 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SyncGroupsOperations.cs @@ -0,0 +1,3416 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2 +{ + using System.Linq; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// SyncGroupsOperations operations. + /// + internal partial class SyncGroupsOperations : Microsoft.Rest.IServiceOperations, ISyncGroupsOperations + { + /// + /// Initializes a new instance of the SyncGroupsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SyncGroupsOperations (SqlManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + this.Client = client; + } + + /// + /// Gets a reference to the SqlManagementClient + /// + public SqlManagementClient Client { get; private set; } + + /// + /// Gets a collection of sync database ids. + /// + /// + /// The name of the region where the resource is located. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListSyncDatabaseIdsWithHttpMessagesAsync(string locationName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (locationName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "locationName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("locationName", locationName); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "ListSyncDatabaseIds", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Sql/locations/{locationName}/syncDatabaseIds").ToString(); + _url = _url.Replace("{locationName}", System.Uri.EscapeDataString(locationName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Lists sync groups under a hub database. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListByDatabaseWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "ListByDatabase", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Gets a sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Creates or updates a sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The requested sync group resource state. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // Send Request + Microsoft.Rest.Azure.AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await this.Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // Send Request + Microsoft.Rest.Azure.AzureOperationHeaderResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, customHeaders, cancellationToken).ConfigureAwait(false); + return await this.Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates a sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The requested sync group resource state. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // Send Request + Microsoft.Rest.Azure.AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await this.Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Cancels a sync group synchronization. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task CancelSyncWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "CancelSync", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/cancelSync").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Gets a collection of hub database schemas. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListHubSchemasWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "ListHubSchemas", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/hubSchemas").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Gets a collection of sync group logs. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// Get logs generated after this time. + /// + /// + /// Get logs generated before this time. + /// + /// + /// The types of logs to retrieve. + /// + /// + /// The continuation token for this operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListLogsWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string startTime, string endTime, string type, string continuationToken = default(string), System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (startTime == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "startTime"); + } + + if (endTime == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "endTime"); + } + + if (type == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "type"); + } + + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + tracingParameters.Add("startTime", startTime); + tracingParameters.Add("endTime", endTime); + tracingParameters.Add("type", type); + tracingParameters.Add("continuationToken", continuationToken); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "ListLogs", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/logs").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (startTime != null) + { + _queryParameters.Add(string.Format("startTime={0}", System.Uri.EscapeDataString(startTime))); + } + if (endTime != null) + { + _queryParameters.Add(string.Format("endTime={0}", System.Uri.EscapeDataString(endTime))); + } + if (type != null) + { + _queryParameters.Add(string.Format("type={0}", System.Uri.EscapeDataString(type))); + } + if (continuationToken != null) + { + _queryParameters.Add(string.Format("continuationToken={0}", System.Uri.EscapeDataString(continuationToken))); + } + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Refreshes a hub database schema. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> RefreshHubSchemaWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // Send Request + Microsoft.Rest.Azure.AzureOperationHeaderResponse _response = await BeginRefreshHubSchemaWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, customHeaders, cancellationToken).ConfigureAwait(false); + return await this.Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Triggers a sync group synchronization. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task TriggerSyncWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "TriggerSync", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/triggerSync").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Creates or updates a sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The requested sync group resource state. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (parameters == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + + tracingParameters.Add("parameters", parameters); + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, this.Client.SerializationSettings); + _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200 && (int)_statusCode != 201 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(this.Client.DeserializationSettings)); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Deletes a sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(this.Client.DeserializationSettings)); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Updates a sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The requested sync group resource state. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (parameters == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "parameters"); + } + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + + tracingParameters.Add("parameters", parameters); + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, this.Client.SerializationSettings); + _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(this.Client.DeserializationSettings)); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Refreshes a hub database schema. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginRefreshHubSchemaWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "BeginRefreshHubSchema", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/refreshHubSchema").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(this.Client.DeserializationSettings)); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Gets a collection of sync database ids. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListSyncDatabaseIdsNextWithHttpMessagesAsync(string nextPageLink, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + if (nextPageLink == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "ListSyncDatabaseIdsNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Lists sync groups under a hub database. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListByDatabaseNextWithHttpMessagesAsync(string nextPageLink, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + if (nextPageLink == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "ListByDatabaseNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Gets a collection of hub database schemas. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListHubSchemasNextWithHttpMessagesAsync(string nextPageLink, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + if (nextPageLink == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "ListHubSchemasNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Gets a collection of sync group logs. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListLogsNextWithHttpMessagesAsync(string nextPageLink, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + if (nextPageLink == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "ListLogsNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SyncGroupsOperationsExtensions.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SyncGroupsOperationsExtensions.cs new file mode 100644 index 000000000000..8f22cb31360a --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SyncGroupsOperationsExtensions.cs @@ -0,0 +1,935 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +namespace Microsoft.Azure.Management.Sql.DataSyncV2 +{ + using Microsoft.Rest.Azure; + using Models; + + /// + /// Extension methods for SyncGroupsOperations + /// + public static partial class SyncGroupsOperationsExtensions + { + /// + /// Gets a collection of sync database ids. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the region where the resource is located. + /// + public static Microsoft.Rest.Azure.IPage ListSyncDatabaseIds(this ISyncGroupsOperations operations, string locationName) + { + return ((ISyncGroupsOperations)operations).ListSyncDatabaseIdsAsync(locationName).GetAwaiter().GetResult(); + } + + /// + /// Gets a collection of sync database ids. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the region where the resource is located. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListSyncDatabaseIdsAsync(this ISyncGroupsOperations operations, string locationName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.ListSyncDatabaseIdsWithHttpMessagesAsync(locationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Lists sync groups under a hub database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + public static Microsoft.Rest.Azure.IPage ListByDatabase(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName) + { + return ((ISyncGroupsOperations)operations).ListByDatabaseAsync(resourceGroupName, serverName, databaseName).GetAwaiter().GetResult(); + } + + /// + /// Lists sync groups under a hub database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListByDatabaseAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.ListByDatabaseWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Gets a sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + public static SyncGroup Get(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName) + { + return ((ISyncGroupsOperations)operations).GetAsync(resourceGroupName, serverName, databaseName, syncGroupName).GetAwaiter().GetResult(); + } + + /// + /// Gets a sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task GetAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Creates or updates a sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + public static SyncGroup CreateOrUpdate(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters) + { + return ((ISyncGroupsOperations)operations).CreateOrUpdateAsync(resourceGroupName, serverName, databaseName, syncGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task CreateOrUpdateAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Deletes a sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + public static SyncGroupsDeleteHeaders Delete(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName) + { + return ((ISyncGroupsOperations)operations).DeleteAsync(resourceGroupName, serverName, databaseName, syncGroupName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task DeleteAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.DeleteWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + /// + /// Updates a sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + public static SyncGroup Update(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters) + { + return ((ISyncGroupsOperations)operations).UpdateAsync(resourceGroupName, serverName, databaseName, syncGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task UpdateAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Cancels a sync group synchronization. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + public static void CancelSync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName) + { + ((ISyncGroupsOperations)operations).CancelSyncAsync(resourceGroupName, serverName, databaseName, syncGroupName).GetAwaiter().GetResult(); + } + + /// + /// Cancels a sync group synchronization. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task CancelSyncAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + (await operations.CancelSyncWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + /// + /// Gets a collection of hub database schemas. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + public static Microsoft.Rest.Azure.IPage ListHubSchemas(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName) + { + return ((ISyncGroupsOperations)operations).ListHubSchemasAsync(resourceGroupName, serverName, databaseName, syncGroupName).GetAwaiter().GetResult(); + } + + /// + /// Gets a collection of hub database schemas. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListHubSchemasAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.ListHubSchemasWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Gets a collection of sync group logs. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// Get logs generated after this time. + /// + /// + /// Get logs generated before this time. + /// + /// + /// The types of logs to retrieve. + /// + /// + /// The continuation token for this operation. + /// + public static Microsoft.Rest.Azure.IPage ListLogs(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string startTime, string endTime, string type, string continuationToken = default(string)) + { + return ((ISyncGroupsOperations)operations).ListLogsAsync(resourceGroupName, serverName, databaseName, syncGroupName, startTime, endTime, type, continuationToken).GetAwaiter().GetResult(); + } + + /// + /// Gets a collection of sync group logs. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// Get logs generated after this time. + /// + /// + /// Get logs generated before this time. + /// + /// + /// The types of logs to retrieve. + /// + /// + /// The continuation token for this operation. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListLogsAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string startTime, string endTime, string type, string continuationToken = default(string), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.ListLogsWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, startTime, endTime, type, continuationToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Refreshes a hub database schema. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + public static SyncGroupsRefreshHubSchemaHeaders RefreshHubSchema(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName) + { + return ((ISyncGroupsOperations)operations).RefreshHubSchemaAsync(resourceGroupName, serverName, databaseName, syncGroupName).GetAwaiter().GetResult(); + } + + /// + /// Refreshes a hub database schema. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task RefreshHubSchemaAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.RefreshHubSchemaWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + /// + /// Triggers a sync group synchronization. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + public static void TriggerSync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName) + { + ((ISyncGroupsOperations)operations).TriggerSyncAsync(resourceGroupName, serverName, databaseName, syncGroupName).GetAwaiter().GetResult(); + } + + /// + /// Triggers a sync group synchronization. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task TriggerSyncAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + (await operations.TriggerSyncWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + /// + /// Creates or updates a sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + public static SyncGroup BeginCreateOrUpdate(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters) + { + return ((ISyncGroupsOperations)operations).BeginCreateOrUpdateAsync(resourceGroupName, serverName, databaseName, syncGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginCreateOrUpdateAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Deletes a sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + public static SyncGroupsDeleteHeaders BeginDelete(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName) + { + return ((ISyncGroupsOperations)operations).BeginDeleteAsync(resourceGroupName, serverName, databaseName, syncGroupName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginDeleteAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + /// + /// Updates a sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + public static SyncGroup BeginUpdate(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters) + { + return ((ISyncGroupsOperations)operations).BeginUpdateAsync(resourceGroupName, serverName, databaseName, syncGroupName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates a sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginUpdateAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, SyncGroup parameters, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Refreshes a hub database schema. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + public static SyncGroupsRefreshHubSchemaHeaders BeginRefreshHubSchema(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName) + { + return ((ISyncGroupsOperations)operations).BeginRefreshHubSchemaAsync(resourceGroupName, serverName, databaseName, syncGroupName).GetAwaiter().GetResult(); + } + + /// + /// Refreshes a hub database schema. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginRefreshHubSchemaAsync(this ISyncGroupsOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.BeginRefreshHubSchemaWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + /// + /// Gets a collection of sync database ids. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static Microsoft.Rest.Azure.IPage ListSyncDatabaseIdsNext(this ISyncGroupsOperations operations, string nextPageLink) + { + return ((ISyncGroupsOperations)operations).ListSyncDatabaseIdsNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets a collection of sync database ids. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListSyncDatabaseIdsNextAsync(this ISyncGroupsOperations operations, string nextPageLink, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.ListSyncDatabaseIdsNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Lists sync groups under a hub database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static Microsoft.Rest.Azure.IPage ListByDatabaseNext(this ISyncGroupsOperations operations, string nextPageLink) + { + return ((ISyncGroupsOperations)operations).ListByDatabaseNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists sync groups under a hub database. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListByDatabaseNextAsync(this ISyncGroupsOperations operations, string nextPageLink, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.ListByDatabaseNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Gets a collection of hub database schemas. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static Microsoft.Rest.Azure.IPage ListHubSchemasNext(this ISyncGroupsOperations operations, string nextPageLink) + { + return ((ISyncGroupsOperations)operations).ListHubSchemasNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets a collection of hub database schemas. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListHubSchemasNextAsync(this ISyncGroupsOperations operations, string nextPageLink, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.ListHubSchemasNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Gets a collection of sync group logs. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static Microsoft.Rest.Azure.IPage ListLogsNext(this ISyncGroupsOperations operations, string nextPageLink) + { + return ((ISyncGroupsOperations)operations).ListLogsNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets a collection of sync group logs. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListLogsNextAsync(this ISyncGroupsOperations operations, string nextPageLink, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.ListLogsNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + } +} diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SyncMembersOperations.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SyncMembersOperations.cs new file mode 100644 index 000000000000..bfd8b9f64299 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SyncMembersOperations.cs @@ -0,0 +1,2253 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.Sql.DataSyncV2 +{ + using System.Linq; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// SyncMembersOperations operations. + /// + internal partial class SyncMembersOperations : Microsoft.Rest.IServiceOperations, ISyncMembersOperations + { + /// + /// Initializes a new instance of the SyncMembersOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SyncMembersOperations (SqlManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + this.Client = client; + } + + /// + /// Gets a reference to the SqlManagementClient + /// + public SqlManagementClient Client { get; private set; } + + /// + /// Lists sync members in the given sync group. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListBySyncGroupWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "ListBySyncGroup", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Gets a sync member. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> GetWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (syncMemberName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncMemberName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + tracingParameters.Add("syncMemberName", syncMemberName); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{syncMemberName}", System.Uri.EscapeDataString(syncMemberName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Creates or updates a sync member. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The requested sync member resource state. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // Send Request + Microsoft.Rest.Azure.AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await this.Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes a sync member. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // Send Request + Microsoft.Rest.Azure.AzureOperationHeaderResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, customHeaders, cancellationToken).ConfigureAwait(false); + return await this.Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates an existing sync member. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The requested sync member resource state. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // Send Request + Microsoft.Rest.Azure.AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await this.Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Refreshes a sync member database schema. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async System.Threading.Tasks.Task> RefreshMemberSchemaWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // Send Request + Microsoft.Rest.Azure.AzureOperationHeaderResponse _response = await BeginRefreshMemberSchemaWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, customHeaders, cancellationToken).ConfigureAwait(false); + return await this.Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a sync member database schema. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListMemberSchemasWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (syncMemberName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncMemberName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + tracingParameters.Add("syncMemberName", syncMemberName); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "ListMemberSchemas", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/schemas").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{syncMemberName}", System.Uri.EscapeDataString(syncMemberName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Creates or updates a sync member. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The requested sync member resource state. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (parameters == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (syncMemberName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncMemberName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + tracingParameters.Add("syncMemberName", syncMemberName); + + tracingParameters.Add("parameters", parameters); + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{syncMemberName}", System.Uri.EscapeDataString(syncMemberName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, this.Client.SerializationSettings); + _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200 && (int)_statusCode != 201 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(this.Client.DeserializationSettings)); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Deletes a sync member. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (syncMemberName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncMemberName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + tracingParameters.Add("syncMemberName", syncMemberName); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{syncMemberName}", System.Uri.EscapeDataString(syncMemberName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(this.Client.DeserializationSettings)); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Updates an existing sync member. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The requested sync member resource state. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (parameters == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "parameters"); + } + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (syncMemberName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncMemberName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + tracingParameters.Add("syncMemberName", syncMemberName); + + tracingParameters.Add("parameters", parameters); + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{syncMemberName}", System.Uri.EscapeDataString(syncMemberName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, this.Client.SerializationSettings); + _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(this.Client.DeserializationSettings)); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Refreshes a sync member database schema. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task> BeginRefreshMemberSchemaWithHttpMessagesAsync(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (resourceGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "resourceGroupName"); + } + + if (serverName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "serverName"); + } + + if (databaseName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "databaseName"); + } + + if (syncGroupName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncGroupName"); + } + + if (syncMemberName == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "syncMemberName"); + } + + if (this.Client.SubscriptionId == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("serverName", serverName); + tracingParameters.Add("databaseName", databaseName); + tracingParameters.Add("syncGroupName", syncGroupName); + tracingParameters.Add("syncMemberName", syncMemberName); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "BeginRefreshMemberSchema", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/syncGroups/{syncGroupName}/syncMembers/{syncMemberName}/refreshSchema").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{serverName}", System.Uri.EscapeDataString(serverName)); + _url = _url.Replace("{databaseName}", System.Uri.EscapeDataString(databaseName)); + _url = _url.Replace("{syncGroupName}", System.Uri.EscapeDataString(syncGroupName)); + _url = _url.Replace("{syncMemberName}", System.Uri.EscapeDataString(syncMemberName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(this.Client.SubscriptionId)); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationHeaderResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(this.Client.DeserializationSettings)); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Lists sync members in the given sync group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListBySyncGroupNextWithHttpMessagesAsync(string nextPageLink, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + if (nextPageLink == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "ListBySyncGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + /// + /// Gets a sync member database schema. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async System.Threading.Tasks.Task>> ListMemberSchemasNextWithHttpMessagesAsync(string nextPageLink, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + if (nextPageLink == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "ListMemberSchemasNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + // Serialize Request + string _requestContent = null; + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + } +} \ No newline at end of file diff --git a/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SyncMembersOperationsExtensions.cs b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SyncMembersOperationsExtensions.cs new file mode 100644 index 000000000000..552794ff5125 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/GeneratedSqlDataSync_2025_02_01/SyncMembersOperationsExtensions.cs @@ -0,0 +1,725 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +namespace Microsoft.Azure.Management.Sql.DataSyncV2 +{ + using Microsoft.Rest.Azure; + using Models; + + /// + /// Extension methods for SyncMembersOperations + /// + public static partial class SyncMembersOperationsExtensions + { + /// + /// Lists sync members in the given sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + public static Microsoft.Rest.Azure.IPage ListBySyncGroup(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName) + { + return ((ISyncMembersOperations)operations).ListBySyncGroupAsync(resourceGroupName, serverName, databaseName, syncGroupName).GetAwaiter().GetResult(); + } + + /// + /// Lists sync members in the given sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListBySyncGroupAsync(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.ListBySyncGroupWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Gets a sync member. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + public static SyncMember Get(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName) + { + return ((ISyncMembersOperations)operations).GetAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName).GetAwaiter().GetResult(); + } + + /// + /// Gets a sync member. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task GetAsync(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Creates or updates a sync member. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + public static SyncMember CreateOrUpdate(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters) + { + return ((ISyncMembersOperations)operations).CreateOrUpdateAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a sync member. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task CreateOrUpdateAsync(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Deletes a sync member. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + public static SyncMembersDeleteHeaders Delete(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName) + { + return ((ISyncMembersOperations)operations).DeleteAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a sync member. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task DeleteAsync(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.DeleteWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + /// + /// Updates an existing sync member. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + public static SyncMember Update(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters) + { + return ((ISyncMembersOperations)operations).UpdateAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing sync member. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task UpdateAsync(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Refreshes a sync member database schema. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + public static SyncMembersRefreshMemberSchemaHeaders RefreshMemberSchema(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName) + { + return ((ISyncMembersOperations)operations).RefreshMemberSchemaAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName).GetAwaiter().GetResult(); + } + + /// + /// Refreshes a sync member database schema. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task RefreshMemberSchemaAsync(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.RefreshMemberSchemaWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + /// + /// Gets a sync member database schema. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + public static Microsoft.Rest.Azure.IPage ListMemberSchemas(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName) + { + return ((ISyncMembersOperations)operations).ListMemberSchemasAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName).GetAwaiter().GetResult(); + } + + /// + /// Gets a sync member database schema. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListMemberSchemasAsync(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.ListMemberSchemasWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Creates or updates a sync member. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + public static SyncMember BeginCreateOrUpdate(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters) + { + return ((ISyncMembersOperations)operations).BeginCreateOrUpdateAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates a sync member. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginCreateOrUpdateAsync(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Deletes a sync member. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + public static SyncMembersDeleteHeaders BeginDelete(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName) + { + return ((ISyncMembersOperations)operations).BeginDeleteAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a sync member. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginDeleteAsync(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + /// + /// Updates an existing sync member. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + public static SyncMember BeginUpdate(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters) + { + return ((ISyncMembersOperations)operations).BeginUpdateAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Updates an existing sync member. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginUpdateAsync(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, SyncMember parameters, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Refreshes a sync member database schema. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + public static SyncMembersRefreshMemberSchemaHeaders BeginRefreshMemberSchema(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName) + { + return ((ISyncMembersOperations)operations).BeginRefreshMemberSchemaAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName).GetAwaiter().GetResult(); + } + + /// + /// Refreshes a sync member database schema. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group that contains the resource. You can obtain + /// this value from the Azure Resource Manager API or the portal. + /// + /// + /// The name of the server. + /// + /// + /// The name of the database on which the sync group is hosted. + /// + /// + /// The name of the sync group on which the sync member is hosted. + /// + /// + /// The name of the sync member. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task BeginRefreshMemberSchemaAsync(this ISyncMembersOperations operations, string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.BeginRefreshMemberSchemaWithHttpMessagesAsync(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Headers; + } + } + /// + /// Lists sync members in the given sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static Microsoft.Rest.Azure.IPage ListBySyncGroupNext(this ISyncMembersOperations operations, string nextPageLink) + { + return ((ISyncMembersOperations)operations).ListBySyncGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists sync members in the given sync group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListBySyncGroupNextAsync(this ISyncMembersOperations operations, string nextPageLink, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.ListBySyncGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// + /// Gets a sync member database schema. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static Microsoft.Rest.Azure.IPage ListMemberSchemasNext(this ISyncMembersOperations operations, string nextPageLink) + { + return ((ISyncMembersOperations)operations).ListMemberSchemasNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets a sync member database schema. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListMemberSchemasNextAsync(this ISyncMembersOperations operations, string nextPageLink, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.ListMemberSchemasNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + } +} diff --git a/src/Sql/Sql.Management.Sdk/README.DataSyncV2.md b/src/Sql/Sql.Management.Sdk/README.DataSyncV2.md new file mode 100644 index 000000000000..27e6e748eba9 --- /dev/null +++ b/src/Sql/Sql.Management.Sdk/README.DataSyncV2.md @@ -0,0 +1,37 @@ +# Overall +This directory contains the service clients of Az.Sql module for the Sql Data Sync V2 API version 2025-02-01. + +## Run Generation +In this directory, run AutoRest: +``` +autorest --reset +autorest README.DataSyncV2.md --use:@autorest/powershell@4.x +``` + +### AutoRest Configuration +> see https://aka.ms/autorest + +``` yaml +isSdkGenerator: true +powershell: true +clear-output-folder: true +reflect-api-versions: true +openapi-type: arm +azure-arm: true +license-header: MICROSOFT_MIT_NO_VERSION +title: SqlManagementClient +use-extension: + "@autorest/powershell": "4.x" +``` + +### +``` yaml +commit: 37d29762e68000fc58e03dcefada999f3876f0af // TODO - Update with commit # of Azure-rest-api-specs +input-file: + - SyncGroups.json // TODO - Replace with the actual file names + - SyncMembers.json // TODO - Replace with the actual file names + +output-folder: GeneratedSqlDataSync_2025_02_01 + +namespace: Microsoft.Azure.Management.Sql.DataSyncV2 +``` diff --git a/src/Sql/Sql/Az.Sql.psd1 b/src/Sql/Sql/Az.Sql.psd1 index 6256f6185d73..41467fc72d33 100644 --- a/src/Sql/Sql/Az.Sql.psd1 +++ b/src/Sql/Sql/Az.Sql.psd1 @@ -318,7 +318,8 @@ CmdletsToExport = 'Add-AzSqlDatabaseToFailoverGroup', 'Add-AzSqlElasticJobStep', 'Update-AzSqlServerAdvancedThreatProtectionSetting', 'Update-AzSqlServerVulnerabilityAssessmentSetting', 'Update-AzSqlSyncGroup', 'Update-AzSqlSyncMember', - 'Update-AzSqlSyncSchema' + 'Update-AzSqlSyncSchema', 'New-AzSqlSyncGroupV2', + 'Update-AzSqlSyncGroupV2', 'New-AzSqlSyncMemberV2', 'Update-AzSqlSyncMemberV2' # Variables to export from this module # VariablesToExport = @() diff --git a/src/Sql/Sql/ChangeLog.md b/src/Sql/Sql/ChangeLog.md index fd27f9901722..0f0f94e221e9 100644 --- a/src/Sql/Sql/ChangeLog.md +++ b/src/Sql/Sql/ChangeLog.md @@ -19,6 +19,12 @@ --> ## Upcoming Release * Fixed `New-AzSqlDatabaseExport` and `New-AzSqlDatabaseImport` to use SQL Authentication with ManagedIdentity without any mandatory password +* Added new DataSync cmdlets to support Entra ID authentication for hub and member databases on Azure. Following are the cmdlets: + - `New-AzSqlSyncGroupV2` + - `Update-AzSqlSyncGroupV2` + - `New-AzSqlSyncMemberV2` + - `Update-AzSqlSyncMemberV2` + ## Version 6.0.5 * Updated `DatabaseOperations` Api to version `2024-11-01-preview` for .Net Sdk diff --git a/src/Sql/Sql/Data Sync/Cmdlet/AzureSqlSyncGroupCmdletBaseV2.cs b/src/Sql/Sql/Data Sync/Cmdlet/AzureSqlSyncGroupCmdletBaseV2.cs new file mode 100644 index 000000000000..aa589c1de7e5 --- /dev/null +++ b/src/Sql/Sql/Data Sync/Cmdlet/AzureSqlSyncGroupCmdletBaseV2.cs @@ -0,0 +1,103 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- +using Microsoft.Azure.Commands.Sql.Common; +using Microsoft.Azure.Commands.Sql.DataSync.Model; +using Microsoft.Azure.Commands.Sql.DataSync.Services; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.IO; +using System.Management.Automation; + +namespace Microsoft.Azure.Commands.Sql.DataSync.Cmdlet +{ + /// + /// The base class for all sync group cmdlets + /// + public abstract class AzureSqlSyncGroupCmdletBaseV2 : AzureSqlDatabaseCmdletBase, AzureSqlDataSyncAdapterV2> + { + /// + /// Creation and initialization of the ModelAdapter object + /// + /// An initialized and ready to use ModelAdapter object + protected override AzureSqlDataSyncAdapterV2 InitModelAdapter() + { + return new AzureSqlDataSyncAdapterV2(DefaultProfile.DefaultContext); + } + + /// + /// Construct schema for schema file + /// + /// The path of the schema file + /// A schema object of member database + protected static AzureSqlSyncGroupSchemaModelV2 ConstructSchemaFromFileV2(string filePath) + { + try + { + JObject jSchema = JObject.Parse(File.ReadAllText(filePath)); + return ConstructSchemaFromJObjectV2(jSchema); + } + catch (Newtonsoft.Json.JsonReaderException) + { + throw new PSArgumentException("The schema file is empty or invalid!", "SchemaFile"); + } + } + + /// + /// Construct schema for schema object + /// + /// JObject containing description of the schema + /// A schema object of member database + public static AzureSqlSyncGroupSchemaModelV2 ConstructSchemaFromJObjectV2(JObject jSchema) + { + AzureSqlSyncGroupSchemaModelV2 schema = new AzureSqlSyncGroupSchemaModelV2(); + JToken masterSyncMemberName = jSchema.GetValue("masterSyncMemberName", StringComparison.InvariantCultureIgnoreCase); + schema.MasterSyncMemberName = masterSyncMemberName == null ? null : masterSyncMemberName.ToString(); + List tables = new List(); + JArray jTables = (JArray)jSchema.GetValue("tables", StringComparison.InvariantCultureIgnoreCase); + if (jTables != null) + { + foreach (var jTableToken in jTables.Children()) + { + if (jTableToken.Type == JTokenType.Object) + { + JObject jTable = (JObject)jTableToken; + AzureSqlSyncGroupSchemaTableModelV2 table = new AzureSqlSyncGroupSchemaTableModelV2(); + JToken tableQuotedNameToken = jTable.GetValue("quotedName", StringComparison.InvariantCultureIgnoreCase); + table.QuotedName = tableQuotedNameToken == null ? null : tableQuotedNameToken.ToString(); + List columns = new List(); + JArray jColumns = (JArray)jTable.GetValue("columns", StringComparison.InvariantCultureIgnoreCase); + if (jColumns != null) + { + foreach (var jColumnToken in jColumns.Children()) + { + if (jColumnToken.Type == JTokenType.Object) + { + AzureSqlSyncGroupSchemaColumnModelV2 column = new AzureSqlSyncGroupSchemaColumnModelV2(); + JToken columnQuotedNameToken = ((JObject)jColumnToken).GetValue("quotedName", StringComparison.InvariantCultureIgnoreCase); + column.QuotedName = columnQuotedNameToken == null ? null : columnQuotedNameToken.ToString(); + columns.Add(column); + } + } + } + table.Columns = columns; + tables.Add(table); + } + } + } + schema.Tables = tables; + return schema; + } + } +} diff --git a/src/Sql/Sql/Data Sync/Cmdlet/AzureSqlSyncMemberCmdletBaseV2.cs b/src/Sql/Sql/Data Sync/Cmdlet/AzureSqlSyncMemberCmdletBaseV2.cs new file mode 100644 index 000000000000..9d04903ec6f0 --- /dev/null +++ b/src/Sql/Sql/Data Sync/Cmdlet/AzureSqlSyncMemberCmdletBaseV2.cs @@ -0,0 +1,46 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System.Management.Automation; +using System.Collections.Generic; +using Microsoft.Azure.Commands.Sql.Common; +using Microsoft.Azure.Commands.Sql.DataSync.Model; +using Microsoft.Azure.Commands.Sql.DataSync.Services; + +namespace Microsoft.Azure.Commands.Sql.DataSync.Cmdlet +{ + /// + /// The base class for all sync member cmdlets + /// + public abstract class AzureSqlSyncMemberCmdletBaseV2 : AzureSqlDatabaseCmdletBase, AzureSqlDataSyncAdapterV2> + { + /// + /// Gets or sets the sync group name + /// + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, + Position = 3, + HelpMessage = "The sync group name.")] + [ValidateNotNullOrEmpty] + public string SyncGroupName { get; set; } + + /// + /// Creation and initialization of the ModelAdapter object + /// + /// An initialized and ready to use ModelAdapter object + protected override AzureSqlDataSyncAdapterV2 InitModelAdapter() + { + return new AzureSqlDataSyncAdapterV2(DefaultProfile.DefaultContext); + } + } +} diff --git a/src/Sql/Sql/Data Sync/Cmdlet/NewAzureSqlSyncGroupV2.cs b/src/Sql/Sql/Data Sync/Cmdlet/NewAzureSqlSyncGroupV2.cs new file mode 100644 index 000000000000..38b9d202c154 --- /dev/null +++ b/src/Sql/Sql/Data Sync/Cmdlet/NewAzureSqlSyncGroupV2.cs @@ -0,0 +1,252 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; +using Microsoft.Azure.Commands.Sql.DataSync.Model; +using Microsoft.Azure.Management.Sql.DataSyncV2.Models; +using Microsoft.Rest.Azure; +using Newtonsoft.Json.Linq; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Management.Automation; + +namespace Microsoft.Azure.Commands.Sql.DataSync.Cmdlet +{ + /// + /// Cmdlet to create a new sync group + /// + [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "SqlSyncGroupV2", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium), OutputType(typeof(AzureSqlSyncGroupModelV2))] + public class NewAzureSqlSyncGroupV2 : AzureSqlSyncGroupCmdletBaseV2 + { + /// + /// Gets or sets the sync group name + /// + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, + Position = 3, + HelpMessage = "The sync group name.")] + [Alias("SyncGroupName")] + [ValidateNotNullOrEmpty] + public string Name { get; set; } + + /// + /// Gets or sets the name of the database used to store sync related metadata + /// + [Parameter(Mandatory = true, + HelpMessage = "The database used to store sync related metadata.")] + [ResourceNameCompleter("Microsoft.Sql/servers/databases", "SyncDatabaseResourceGroupName", "SyncDatabaseServerName")] + [ValidateNotNullOrEmpty] + public string SyncDatabaseName { get; set; } + + /// + /// Gets or sets the name of the server on which sync metadata database is hosted + /// + [Parameter(Mandatory = true, + HelpMessage = "The server on which the sync metadata database is hosted.")] + [ResourceNameCompleter("Microsoft.Sql/servers", "SyncDatabaseResourceGroupName")] + [ValidateNotNullOrEmpty] + public string SyncDatabaseServerName { get; set; } + + /// + /// Gets or sets the name of the resource group the sync metadata database belongs to + /// + [Parameter(Mandatory = true, + HelpMessage = "The resource group the sync metadata database belongs to.")] + [ResourceGroupCompleter] + [ValidateNotNullOrEmpty] + public string SyncDatabaseResourceGroupName { get; set; } + + /// + /// Gets or sets the frequency (in seconds) of doing data synchronization. + /// + [Parameter(Mandatory = false, HelpMessage = "The frequency (in seconds) of doing data synchronization. Default is -1, which means the auto synchronization is not enabled.")] + public int IntervalInSeconds { get; set; } + + /// + /// Gets or sets the hub database credential of the sync group + /// + [Parameter(Mandatory = false, HelpMessage = "The SQL authentication credential of the hub database.")] + [ValidateNotNull] + public PSCredential DatabaseCredential { get; set; } + + /// + /// Gets or sets the policy of resolving conflicts between hub and member database in the sync group + /// + [Parameter(Mandatory = false, + HelpMessage = "The policy of resolving conflicts between hub and member database in the sync group.")] + [ValidateSet("HubWin", "MemberWin", IgnoreCase = true)] + public string ConflictResolutionPolicy { get; set; } + + /// + /// Gets or sets the path of the schema file + /// + [Parameter(Mandatory = false, HelpMessage = "The path of the schema file.")] + [ValidateNotNullOrEmpty] + public string SchemaFile { get; set; } + + /// + /// Gets or sets if private link should be used + /// + [Parameter(Mandatory = false, HelpMessage = "Use a private link connection when connecting to the hub of this sync group.")] + public SwitchParameter UsePrivateLinkConnection { get; set; } + + /// + /// Gets or sets the Database Authentication type of the hub database + /// + [Parameter(Mandatory = false, HelpMessage = "The Database Authentication type of the hub database.")] + [ValidateSet("password", "userAssigned", IgnoreCase = true)] + public string HubDatabaseAuthenticationType { get; set; } + + /// + /// Gets or sets the identity ID of the hub database in case of user assigned identity authentication + /// + [Parameter(Mandatory = false, HelpMessage = "The identity ID of the hub database in case of UAMI Authentication.")] + public string IdentityId { get; set; } + + /// + /// The id of database used to store sync related metadata + /// + private string syncDatabaseId = null; + + /// + /// Get the entities from the service + /// + /// The list of entities + protected override IEnumerable GetEntity() + { + // We try to get the sync group. Since this is a create, we don't want the sync group to exist + try + { + ModelAdapter.GetSyncGroup(this.ResourceGroupName, this.ServerName, this.DatabaseName, this.Name); + } + catch (CloudException ex) + { + if (ex.Response.StatusCode == System.Net.HttpStatusCode.NotFound) + { + // This is what we want. We looked and there is no sync group with this name. + return null; + } + + // Unexpected exception encountered + throw; + } + + // The sync group already exists + throw new PSArgumentException( + string.Format(Microsoft.Azure.Commands.Sql.Properties.Resources.SyncGroupNameExists, this.Name, this.DatabaseName), + "SyncGroupName"); + } + + /// + /// Create the model from user input + /// + /// Model retrieved from service + /// The model that was passed in + protected override IEnumerable ApplyUserInputToModel(IEnumerable model) + { + List newEntity = new List(); + AzureSqlSyncGroupModelV2 newModel = new AzureSqlSyncGroupModelV2() + { + ResourceGroupName = this.ResourceGroupName, + ServerName = this.ServerName, + DatabaseName = this.DatabaseName, + SyncGroupName = this.Name, + ConflictResolutionPolicy = this.ConflictResolutionPolicy != null ? this.ConflictResolutionPolicy.ToString() : null, + }; + + if (!MyInvocation.BoundParameters.ContainsKey(nameof(HubDatabaseAuthenticationType)) || + this.HubDatabaseAuthenticationType.Equals("password", System.StringComparison.OrdinalIgnoreCase)) + { + if (!MyInvocation.BoundParameters.ContainsKey(nameof(DatabaseCredential)) || + this.DatabaseCredential == null || + string.IsNullOrEmpty(this.DatabaseCredential.UserName)) + { + throw new PSArgumentException( + Microsoft.Azure.Commands.Sql.Properties.Resources.DatabaseCredentialRequired, + "HubDatabaseCredentials"); + } + + newModel.HubDatabaseUserName = this.DatabaseCredential.UserName; + newModel.HubDatabasePassword = this.DatabaseCredential.Password; + + newModel.Identity = new DataSyncParticipantIdentity + { + Type = "None" + }; + } + else if (this.HubDatabaseAuthenticationType.Equals("userAssigned", System.StringComparison.OrdinalIgnoreCase)) + { + if (!MyInvocation.BoundParameters.ContainsKey(nameof(IdentityId)) || + string.IsNullOrEmpty(this.IdentityId)) + { + throw new PSArgumentException( + Microsoft.Azure.Commands.Sql.Properties.Resources.IdentityIdRequired, + "UserAssignedIdentityId"); + } + + newModel.Identity = AzureSqlSyncIdentityHelper.CreateUserAssignedIdentity(this.IdentityId); + } + else + { + throw new PSArgumentException( + Microsoft.Azure.Commands.Sql.Properties.Resources.InvalidDatabaseAuthenticationType, + "HubDatabaseAuthenticationType"); + } + + + if (MyInvocation.BoundParameters.ContainsKey("IntervalInSeconds")) + { + newModel.IntervalInSeconds = this.IntervalInSeconds; + } + + newModel.UsePrivateLinkConnection = UsePrivateLinkConnection.IsPresent; + + if (MyInvocation.BoundParameters.ContainsKey("SyncDatabaseResourceGroupName") + && MyInvocation.BoundParameters.ContainsKey("SyncDatabaseServerName") + && MyInvocation.BoundParameters.ContainsKey("SyncDatabaseName")) + { + this.syncDatabaseId = string.Format("resourceGroups/{0}/providers/Microsoft.Sql/servers/{1}/databases/{2}", + this.SyncDatabaseResourceGroupName, this.SyncDatabaseServerName, this.SyncDatabaseName); + } + + // if schema file is specified + if (MyInvocation.BoundParameters.ContainsKey("SchemaFile")) + { + try + { + newModel.Schema = ConstructSchemaFromFileV2(this.SchemaFile); + } + catch (CloudException ex) + { + // There are problems with schema file + throw new PSArgumentException(ex.Response.ToString(), "SchemaFile"); + } + } + newEntity.Add(newModel); + return newEntity; + } + + /// + /// Create the new sync group + /// + /// The output of apply user input to model + /// The input entity + protected override IEnumerable PersistChanges(IEnumerable entity) + { + return new List() { + ModelAdapter.CreateSyncGroup(entity.First(), this.syncDatabaseId) + }; + } + } +} diff --git a/src/Sql/Sql/Data Sync/Cmdlet/NewAzureSqlSyncMemberV2.cs b/src/Sql/Sql/Data Sync/Cmdlet/NewAzureSqlSyncMemberV2.cs new file mode 100644 index 000000000000..dc681dbc2556 --- /dev/null +++ b/src/Sql/Sql/Data Sync/Cmdlet/NewAzureSqlSyncMemberV2.cs @@ -0,0 +1,314 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; +using Microsoft.Azure.Commands.Sql.DataSync.Model; +using Microsoft.Azure.Commands.Sql.Properties; +using Microsoft.Azure.Management.Sql.DataSyncV2.Models; +using Microsoft.Azure.Management.Sql.LegacySdk.Models; +using Microsoft.Rest.Azure; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Management.Automation; +using System.Security; + +namespace Microsoft.Azure.Commands.Sql.DataSync.Cmdlet +{ + /// + /// Cmdlet to create a new sync member + /// + [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "SqlSyncMemberV2", SupportsShouldProcess = true, DefaultParameterSetName = AzureSqlSet, ConfirmImpact = ConfirmImpact.Medium), OutputType(typeof(AzureSqlSyncMemberModelV2))] + public class NewAzureSqlSyncMemberV2 : AzureSqlSyncMemberCmdletBaseV2 + { + /// + /// Parameter set name for Azure Sql Database + /// + private const string AzureSqlSet = "AzureSqlDatabase"; + + /// + /// Parameter set name for On Premises Database with sync agent resource ID + /// + private const string OnPremisesSyncAgentResourceIDSet = "OnPremisesDatabaseSyncAgentResourceID"; + + /// + /// Parameter set name for On Premises Database with sync agent component including resource group name, server name, sync agent name + /// + private const string OnPremisesSyncAgentComponentSet = "OnPremisesDatabaseSyncAgentComponent"; + + /// + /// Gets or sets the sync member name + /// + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, + HelpMessage = "The sync member name.")] + [Alias("SyncMemberName")] + [ValidateNotNullOrEmpty] + public string Name { get; set; } + + /// + /// Gets or sets the database type of the member database + /// + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, + HelpMessage = "The database type of the member database.")] + [ValidateSet("SqlServerDatabase", "AzureSqlDatabase", IgnoreCase = true)] + public string MemberDatabaseType { get; set; } + + /// + /// Gets or sets the Azure SQL Server Name of the member database. + /// + [Parameter(Mandatory = true, + ParameterSetName = AzureSqlSet, + HelpMessage = "The Azure SQL Server Name of the member database.")] + [ResourceNameCompleter("Microsoft.Sql/servers", "ResourceGroupName")] + public string MemberServerName { get; set; } + + /// + /// Gets or sets the Azure SQL Database name of the member database. + /// + [Parameter(Mandatory = true, + ParameterSetName = AzureSqlSet, + HelpMessage = "The Azure SQL Database name of the member database.")] + [ResourceNameCompleter("Microsoft.Sql/servers/databases", "ResourceGroupName", "MemberServerName")] + public string MemberDatabaseName { get; set; } + + /// + /// Gets or sets the credential (username and password) of the Azure SQL Database. + /// + [Parameter(Mandatory = true, + ParameterSetName = AzureSqlSet, + HelpMessage = "The credential (username and password) of the Azure SQL Database.")] + public PSCredential MemberDatabaseCredential { get; set; } + + /// + /// Gets or sets the resource group name of the sync agent. + /// + [Parameter(Mandatory = true, + ParameterSetName = OnPremisesSyncAgentComponentSet, + HelpMessage = "The name of the resource group where the sync agent is under.")] + [ResourceGroupCompleter] + [ValidateNotNullOrEmpty] + public string SyncAgentResourceGroupName { get; set; } + + /// + /// Gets or sets the server name of the sync agent. + /// + [Parameter(Mandatory = true, + ParameterSetName = OnPremisesSyncAgentComponentSet, + HelpMessage = "The name of the Azure SQL Server where the sync agent is under.")] + [ResourceNameCompleter("Microsoft.Sql/servers", "SyncAgentResourceGroupName")] + [ValidateNotNullOrEmpty] + public string SyncAgentServerName { get; set; } + + /// + /// Gets or sets the name of sync agent. + /// + [Parameter(Mandatory = true, + ParameterSetName = OnPremisesSyncAgentComponentSet, + HelpMessage = "The name of the sync agent.")] + [ValidateNotNullOrEmpty] + public string SyncAgentName { get; set; } + + /// + /// Gets or sets the id of the SQL server database which is connected by the sync agent. + /// + [Parameter(Mandatory = true, + ParameterSetName = OnPremisesSyncAgentComponentSet, + HelpMessage = "The id of the SQL server database which is connected by the sync agent.")] + [Parameter(Mandatory = true, + ParameterSetName = OnPremisesSyncAgentResourceIDSet, + HelpMessage = "The id of the SQL server database which is connected by the sync agent.")] + [ValidateNotNullOrEmpty] + public string SqlServerDatabaseId { get; set; } + + /// + /// Gets or sets the resource ID of the sync agent. + /// + [Parameter(Mandatory = true, + ParameterSetName = OnPremisesSyncAgentResourceIDSet, + HelpMessage = "The resource ID of the sync agent.")] + [ValidateNotNullOrEmpty] + public string SyncAgentResourceID { get; set; } + + /// + /// Gets or sets the sync direction of this sync member + /// + [Parameter(Mandatory = false, HelpMessage = "The sync direction of this sync member.")] + [ValidateSet("Bidirectional", "OneWayMemberToHub", "OneWayHubToMember", IgnoreCase = true)] + public string SyncDirection { get; set; } + + /// + /// Gets or sets a value indicating whether to use private link connection + /// + [Parameter(Mandatory = false, HelpMessage = "Use a private link connection when connecting to this sync member.")] + public SwitchParameter UsePrivateLinkConnection { get; set; } + + /// + /// Gets or sets the sync member resource Id + /// + /// + /// The sync member database id (only for sync member using Azure SQL Database), e.g. "subscriptions/{subscriptionId}/resourceGroups/{syncDatabaseResourceGroup01}/servers/{syncMemberServer01}/databases/{syncMemberDatabaseName01}" + /// + /// + /// This needs to be a sync member sql azure database id (i.e. full arm uri) so that we can validate calling user's R/W access to this database via RBAC. + /// + [Parameter(Mandatory = false, HelpMessage = "The resource ID for the sync member database, used if UsePrivateLinkConnection is set to true.")] + public string SyncMemberAzureDatabaseResourceId { get; set; } + + /// + /// The id of the sync agent which is connected by the on-premises SQL server. + /// + private string syncAgentId = null; + + /// + /// Gets or sets the Database Authentication type of the sync member database + /// + [Parameter(Mandatory = false, HelpMessage = "The Database Authentication type of the sync member database.")] + [ValidateSet("password", "userAssigned", IgnoreCase = true)] + public string MemberDatabaseAuthenticationType { get; set; } + + /// + /// Gets or sets the identity ID of the sync member database in case of user assigned identity authentication + /// + [Parameter(Mandatory = false, HelpMessage = "The identity ID of the sync member DB in case of UAMI Authentication")] + public string IdentityId { get; set; } + + /// + /// Get the entities from the service + /// + /// The list of entities + protected override IEnumerable GetEntity() + { + // We try to get the sync member. Since this is a create, we don't want the sync member to exist + try + { + ModelAdapter.GetSyncMember(this.ResourceGroupName, this.ServerName, this.DatabaseName, this.SyncGroupName, this.Name); + } + catch (CloudException ex) + { + if (ex.Response.StatusCode == System.Net.HttpStatusCode.NotFound) + { + // This is what we want. We looked and there is no sync member with this name. + return null; + } + + // Unexpected exception encountered + throw; + } + + // The sync member already exists + throw new PSArgumentException( + string.Format(Microsoft.Azure.Commands.Sql.Properties.Resources.SyncMemberNameExists, this.Name, this.SyncGroupName), + "SyncMemberName"); + } + + /// + /// Create the model from user input + /// + /// Model retrieved from service + /// The model that was passed in + protected override IEnumerable ApplyUserInputToModel(IEnumerable model) + { + List newEntity = new List(); + AzureSqlSyncMemberModelV2 newModel = new AzureSqlSyncMemberModelV2() + { + ResourceGroupName = this.ResourceGroupName, + ServerName = this.ServerName, + DatabaseName = this.DatabaseName, + SyncGroupName = this.SyncGroupName, + SyncMemberName = this.Name, + SyncDirection = this.SyncDirection, + MemberDatabaseType = this.MemberDatabaseType + }; + + if (UsePrivateLinkConnection.IsPresent) + { + if (!MyInvocation.BoundParameters.ContainsKey(nameof(SyncMemberAzureDatabaseResourceId))) + { + throw new PSArgumentException( + Microsoft.Azure.Commands.Sql.Properties.Resources.SyncMemberIdRequired, nameof(SyncMemberAzureDatabaseResourceId)); + } + + newModel.UsePrivateLinkConnection = true; + newModel.SyncMemberAzureDatabaseResourceId = this.SyncMemberAzureDatabaseResourceId; + } + + if (ParameterSetName == AzureSqlSet) + { + newModel.MemberDatabaseName = this.MemberDatabaseName; + newModel.MemberServerName = this.MemberServerName; + + if (!MyInvocation.BoundParameters.ContainsKey(nameof(MemberDatabaseAuthenticationType)) || + this.MemberDatabaseAuthenticationType.Equals("password", StringComparison.OrdinalIgnoreCase)) + { + if (!MyInvocation.BoundParameters.ContainsKey(nameof(MemberDatabaseCredential)) + || this.MemberDatabaseCredential == null + || string.IsNullOrEmpty(this.MemberDatabaseCredential.UserName)) + { + throw new PSArgumentException( + Microsoft.Azure.Commands.Sql.Properties.Resources.DatabaseCredentialRequired, nameof(MemberDatabaseCredential)); + } + newModel.MemberDatabaseUserName = this.MemberDatabaseCredential.UserName; + newModel.MemberDatabasePassword = this.MemberDatabaseCredential.Password; + + newModel.Identity = new DataSyncParticipantIdentity + { + Type = "None" + }; + } + else if (this.MemberDatabaseAuthenticationType.Equals("userAssigned", StringComparison.OrdinalIgnoreCase)) + { + if (!MyInvocation.BoundParameters.ContainsKey(nameof(IdentityId)) || + string.IsNullOrEmpty(this.IdentityId)) + { + throw new PSArgumentException( + Microsoft.Azure.Commands.Sql.Properties.Resources.IdentityIdRequired, nameof(IdentityId)); + } + newModel.Identity = AzureSqlSyncIdentityHelper.CreateUserAssignedIdentity(this.IdentityId); + } + else + { + throw new PSArgumentException( + Microsoft.Azure.Commands.Sql.Properties.Resources.InvalidDatabaseAuthenticationType, nameof(MemberDatabaseAuthenticationType)); + } + } + else + { + newModel.SqlServerDatabaseId = this.SqlServerDatabaseId; + if (ParameterSetName == OnPremisesSyncAgentResourceIDSet) + { + newModel.SyncAgentId = this.SyncAgentResourceID; + } + else + { + // "/subscriptions/{id}/" will be added in AzureSqlDataSyncCommunicator + this.syncAgentId = string.Format("resourceGroups/{0}/providers/Microsoft.Sql/servers/{1}/syncAgents/{2}", this.SyncAgentResourceGroupName, this.SyncAgentServerName, this.SyncAgentName); + } + } + newEntity.Add(newModel); + return newEntity; + } + + /// + /// Create the new sync member + /// + /// The output of apply user input to model + /// The input entity + protected override IEnumerable PersistChanges(IEnumerable entity) + { + return new List() { + ModelAdapter.CreateSyncMember(entity.First(), this.syncAgentId) + }; + } + } +} diff --git a/src/Sql/Sql/Data Sync/Cmdlet/UpdateAzureSqlSyncGroupV2.cs b/src/Sql/Sql/Data Sync/Cmdlet/UpdateAzureSqlSyncGroupV2.cs new file mode 100644 index 000000000000..f76085cbe179 --- /dev/null +++ b/src/Sql/Sql/Data Sync/Cmdlet/UpdateAzureSqlSyncGroupV2.cs @@ -0,0 +1,178 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Hyak.Common; +using Microsoft.Azure.Commands.Sql.DataSync.Model; +using Microsoft.Azure.Management.Sql.DataSyncV2.Models; +using System.Collections.Generic; +using System.Linq; +using System.Management.Automation; + +namespace Microsoft.Azure.Commands.Sql.DataSync.Cmdlet +{ + /// + /// Cmdlet to update a existing sync group + /// + [Cmdlet("Update", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "SqlSyncGroupV2", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium), OutputType(typeof(AzureSqlSyncGroupModelV2))] + public class UpdateAzureSqlSyncGroupV2 : AzureSqlSyncGroupCmdletBaseV2 + { + /// + /// Gets or sets the sync group name + /// + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, + Position = 3, + HelpMessage = "The sync group name.")] + [ValidateNotNullOrEmpty] + [Alias("SyncGroupName")] + public string Name { get; set; } + + /// + /// Gets or sets the frequency (in seconds) of doing data synchronization + /// + [Parameter(Mandatory = false, HelpMessage = "The frequency (in seconds) of doing data synchronization. Default is -1, which means the auto synchronization is not enabled.")] + public int IntervalInSeconds { get; set; } + + /// + /// Gets or sets the hub database credential of the sync group + /// + [Parameter(Mandatory = false, HelpMessage = "The SQL authentication credential of the hub database.")] + [ValidateNotNull] + public PSCredential DatabaseCredential { get; set; } + + /// + /// Gets or sets the path of the schema file + /// + [Parameter(Mandatory = false, HelpMessage = "The path of the schema file.")] + public string SchemaFile { get; set; } + + /// + /// Gets or sets if private link should be used + /// + [Parameter(Mandatory = false, HelpMessage = "Whether to use a private link connection when connecting to the hub of this sync group.")] + public bool UsePrivateLinkConnection { get; set; } + + /// + /// Gets or sets the Database Authentication type of the hub database + /// + [Parameter(Mandatory = false, HelpMessage = "The Database Authentication type of the hub database.")] + [ValidateSet("password", "userAssigned", IgnoreCase = true)] + public string HubDatabaseAuthenticationType { get; set; } + + /// + /// Gets or sets the identity ID of the hub database in case of user assigned identity authentication + /// + [Parameter(Mandatory = false, HelpMessage = "The identity ID of the hub database in case of UAMI Authentication")] + public string IdentityId { get; set; } + + /// + /// Get the entities from the service + /// + /// The list of entities + protected override IEnumerable GetEntity() + { + return new List() { + ModelAdapter.GetSyncGroup(this.ResourceGroupName, this.ServerName, this.DatabaseName, this.Name) + }; + } + + /// + /// create the model from user input + /// + /// Model retrieved from service + /// The model that was passed in + protected override IEnumerable ApplyUserInputToModel(IEnumerable model) + { + AzureSqlSyncGroupModelV2 newModel = model.First(); + + if (MyInvocation.BoundParameters.ContainsKey("IntervalInSeconds")) + { + newModel.IntervalInSeconds = this.IntervalInSeconds; + } + + if (MyInvocation.BoundParameters.ContainsKey(nameof(UsePrivateLinkConnection))) + { + newModel.UsePrivateLinkConnection = this.UsePrivateLinkConnection; + } + + // if schema file is specified + if (MyInvocation.BoundParameters.ContainsKey("SchemaFile")) + { + try + { + newModel.Schema = ConstructSchemaFromFileV2(this.SchemaFile); + } + catch (CloudException ex) + { + // There are problems with schema file + throw new PSArgumentException(ex.Response.ToString(), "SchemaFile"); + } + } + + if (!MyInvocation.BoundParameters.ContainsKey(nameof(HubDatabaseAuthenticationType)) || + this.HubDatabaseAuthenticationType.Equals("password", System.StringComparison.OrdinalIgnoreCase)) + { + if (MyInvocation.BoundParameters.ContainsKey(nameof(DatabaseCredential))) + { + newModel.HubDatabaseUserName = this.DatabaseCredential.UserName; + newModel.HubDatabasePassword = this.DatabaseCredential.Password; + } + else + { + newModel.HubDatabaseUserName = null; + newModel.HubDatabasePassword = null; + } + + newModel.Identity = new DataSyncParticipantIdentity + { + Type = "None" + }; + } + else if (this.HubDatabaseAuthenticationType.Equals("userAssigned", System.StringComparison.OrdinalIgnoreCase)) + { + if (!MyInvocation.BoundParameters.ContainsKey(nameof(IdentityId)) || + string.IsNullOrEmpty(this.IdentityId)) + { + newModel.Identity = new DataSyncParticipantIdentity + { + Type = "UserAssigned" + }; + } + else + { + newModel.Identity = AzureSqlSyncIdentityHelper.CreateUserAssignedIdentity(this.IdentityId); + } + } + else + { + throw new PSArgumentException( + Microsoft.Azure.Commands.Sql.Properties.Resources.InvalidDatabaseAuthenticationType, + "HubDatabaseAuthenticationType"); + } + + return model; + } + + /// + /// Update the sync group + /// + /// The output of apply user input to model + /// The input entity + protected override IEnumerable PersistChanges(IEnumerable entity) + { + return new List() { + ModelAdapter.UpdateSyncGroup(entity.First()) + }; + } + } +} diff --git a/src/Sql/Sql/Data Sync/Cmdlet/UpdateAzureSqlSyncMemberV2.cs b/src/Sql/Sql/Data Sync/Cmdlet/UpdateAzureSqlSyncMemberV2.cs new file mode 100644 index 000000000000..f8bbf0fb2c9c --- /dev/null +++ b/src/Sql/Sql/Data Sync/Cmdlet/UpdateAzureSqlSyncMemberV2.cs @@ -0,0 +1,166 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Commands.Sql.DataSync.Model; +using Microsoft.Azure.Management.Sql.DataSyncV2.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Management.Automation; +using System.Security; + +namespace Microsoft.Azure.Commands.Sql.DataSync.Cmdlet +{ + /// + /// Cmdlet to update an existing sync member + /// + [Cmdlet("Update", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "SqlSyncMemberV2", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium), OutputType(typeof(AzureSqlSyncMemberModelV2))] + public class UpdateAzureSqlSyncMemberV2 : AzureSqlSyncMemberCmdletBaseV2 + { + /// + /// Gets or sets the sync member name + /// + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, + HelpMessage = "The sync member name.")] + [Alias("SyncMemberName")] + [ValidateNotNullOrEmpty] + public string Name { get; set; } + + /// + /// Gets or sets the credential (username and password) of the Azure SQL Database. + /// + [Parameter(Mandatory = false, HelpMessage = "The credential (username and password) of the Azure SQL Database.")] + public PSCredential MemberDatabaseCredential { get; set; } + + /// + /// Gets or sets a value indicating whether to use private link connection + /// + [Parameter(Mandatory = false, HelpMessage = "Whether to use private link when connecting to this sync member.")] + public bool? UsePrivateLinkConnection { get; set; } + + /// + /// Gets or sets the sync member resource Id + /// + /// + /// The sync member database id (only for sync member using Azure SQL Database), e.g. "subscriptions/{subscriptionId}/resourceGroups/{syncDatabaseResourceGroup01}/servers/{syncMemberServer01}/databases/{syncMemberDatabaseName01}" + /// + /// + /// This needs to be a sync member sql azure database id (i.e. full arm uri) so that we can validate calling user's R/W access to this database via RBAC. + /// + [Parameter(Mandatory = false, HelpMessage = "The resource ID for the sync member database, used if UsePrivateLinkConnection is set to true.")] + public string SyncMemberAzureDatabaseResourceId { get; set; } + + /// + /// Gets or sets the Database Authentication type of the sync member database + /// + [Parameter(Mandatory = false, HelpMessage = "The Database Authentication type of the sync member database.")] + [ValidateSet("password", "userAssigned", IgnoreCase = true)] + public string MemberDatabaseAuthenticationType { get; set; } + + /// + /// Gets or sets the identity ID of the sync member database in case of user assigned identity authentication + /// + [Parameter(Mandatory = false, HelpMessage = "The identity ID of the sync member DB in case of UAMI Authentication")] + public string IdentityId { get; set; } + + /// + /// Get the entities from the service + /// + /// The list of entities + protected override IEnumerable GetEntity() + { + return new List() { + ModelAdapter.GetSyncMember(this.ResourceGroupName, this.ServerName, this.DatabaseName, this.SyncGroupName, this.Name) + }; + } + + /// + /// Create the model from user input + /// + /// Model retrieved from service + /// The model that was passed in + protected override IEnumerable ApplyUserInputToModel(IEnumerable model) + { + AzureSqlSyncMemberModelV2 newModel = model.First(); + + if (MyInvocation.BoundParameters.ContainsKey(nameof(UsePrivateLinkConnection))) + { + if (this.UsePrivateLinkConnection.GetValueOrDefault() && !MyInvocation.BoundParameters.ContainsKey(nameof(SyncMemberAzureDatabaseResourceId))) + { + throw new PSArgumentException( + Microsoft.Azure.Commands.Sql.Properties.Resources.SyncMemberIdRequired, nameof(SyncMemberAzureDatabaseResourceId)); + } + + newModel.UsePrivateLinkConnection = this.UsePrivateLinkConnection; + newModel.SyncMemberAzureDatabaseResourceId = this.SyncMemberAzureDatabaseResourceId; + } + + + if (!MyInvocation.BoundParameters.ContainsKey(nameof(MemberDatabaseAuthenticationType)) || + this.MemberDatabaseAuthenticationType.Equals("password", StringComparison.OrdinalIgnoreCase)) + { + if (MyInvocation.BoundParameters.ContainsKey("MemberDatabaseCredential")) + { + newModel.MemberDatabaseUserName = this.MemberDatabaseCredential.UserName; + newModel.MemberDatabasePassword = this.MemberDatabaseCredential.Password; + } + else + { + newModel.MemberDatabaseUserName = null; + newModel.MemberDatabasePassword = null; + } + + newModel.Identity = new DataSyncParticipantIdentity + { + Type = "None" + }; + } + else if (this.MemberDatabaseAuthenticationType.Equals("userAssigned", StringComparison.OrdinalIgnoreCase)) + { + if (!MyInvocation.BoundParameters.ContainsKey(nameof(IdentityId)) || + string.IsNullOrEmpty(this.IdentityId)) + { + newModel.Identity = new DataSyncParticipantIdentity + { + Type = "UserAssigned" + }; + } + else + { + newModel.Identity = AzureSqlSyncIdentityHelper.CreateUserAssignedIdentity(this.IdentityId); + } + } + else + { + throw new PSArgumentException( + Microsoft.Azure.Commands.Sql.Properties.Resources.InvalidDatabaseAuthenticationType, + nameof(MemberDatabaseAuthenticationType)); + } + + return model; + } + + /// + /// Update the sync member + /// + /// The output of apply user input to model + /// The input entity + protected override IEnumerable PersistChanges(IEnumerable entity) + { + return new List() { + ModelAdapter.UpdateSyncMember(entity.First()) + }; + } + } +} diff --git a/src/Sql/Sql/Data Sync/Model/AzureSqlSyncGroupModelV2.cs b/src/Sql/Sql/Data Sync/Model/AzureSqlSyncGroupModelV2.cs new file mode 100644 index 000000000000..2cedf38ba7a7 --- /dev/null +++ b/src/Sql/Sql/Data Sync/Model/AzureSqlSyncGroupModelV2.cs @@ -0,0 +1,162 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Management.Sql.DataSyncV2.Models; +using System; +using System.Linq; +using System.Security; + +namespace Microsoft.Azure.Commands.Sql.DataSync.Model +{ + /// + /// Represents a sync group object + /// + public class AzureSqlSyncGroupModelV2 + { + /// + /// Gets or sets the resource Id + /// + public string ResourceId { get; set; } + + /// + /// Gets or sets the resource group name + /// + public string ResourceGroupName { get; set; } + + /// + /// Gets or sets the server name + /// + public string ServerName { get; set; } + + /// + /// Gets or sets the database name + /// + public string DatabaseName { get; set; } + + /// + /// Gets or sets the name of the sync group + /// + public string SyncGroupName { get; set; } + + /// + /// Gets or sets the sync database resource Id + /// + public string SyncDatabaseId { get; set; } + + /// + /// Gets or sets the frequency (in seconds) time of doing data synchronization + /// + public int? IntervalInSeconds { get; set; } + + /// + /// Gets or sets the hub database user name + /// + public string HubDatabaseUserName { get; set; } + + /// + /// Gets or sets the hub database password + /// + public SecureString HubDatabasePassword { get; set; } + + /// + /// Gets or sets the policy of resolving conflicts between hub and member database in the sync group + /// + public string ConflictResolutionPolicy { get; set; } + + /// + /// Gets or sets the sync state of sync group + /// + public string SyncState { get; set; } + + /// + /// Gets or sets the last sync time of a sync group + /// + public DateTime? LastSyncTime { get; set; } + + /// + /// Gets or sets the simple schema of member database + /// + public AzureSqlSyncGroupSchemaModelV2 Schema { get; set; } + + /// + /// Gets or sets if private link connection should be used + /// + public bool? UsePrivateLinkConnection { get; set; } + + /// + /// Gets or sets the identity of the sync group + /// + public DataSyncParticipantIdentity Identity { get; set; } + + // ---- Display helper properties ---- + + /// + /// Gets the identity type of the sync group. + /// Possible values include: 'None', 'SystemAssigned', 'UserAssigned', 'SystemAssignedUserAssigned'. + /// + public string IdentityType { get; private set; } + + /// + /// Gets the Resource ID associated with the sync group EntraID. + /// + public string IdentityId { get; private set; } + + /// + /// Construct AzureSqlSyncGroupModelV2 + /// + public AzureSqlSyncGroupModelV2() + { + + } + + /// + /// Construct AzureSqlSyncGroupModelV2 for Management.Sql.DataSyncV2.Models.syncGroup object + /// + /// Resource group name + /// Server name + /// Database name + /// sync group object + public AzureSqlSyncGroupModelV2(string resourceGroupName, string serverName, string databaseName, SyncGroup syncGroup) + { + ResourceGroupName = resourceGroupName; + ServerName = serverName; + DatabaseName = databaseName; + ResourceId = syncGroup.Id; + SyncGroupName = syncGroup.Name; + IntervalInSeconds = syncGroup.Interval; + SyncDatabaseId = syncGroup.SyncDatabaseId; + HubDatabaseUserName = syncGroup.HubDatabaseUserName; + ConflictResolutionPolicy = syncGroup.ConflictResolutionPolicy == null ? null : syncGroup.ConflictResolutionPolicy.ToString(); + SyncState = syncGroup.SyncState; + LastSyncTime = syncGroup.LastSyncTime; + Schema = syncGroup.Schema == null ? null : new AzureSqlSyncGroupSchemaModelV2(syncGroup.Schema); + UsePrivateLinkConnection = syncGroup.UsePrivateLinkConnection; + Identity = syncGroup.Identity; + if (syncGroup.Identity != null) + { + IdentityType = Identity.Type == null ? null : Identity.Type; + if (Identity.UserAssignedIdentities != null && Identity.UserAssignedIdentities.Count > 0) + { + // Get the first identity resource ID + IdentityId = Identity.UserAssignedIdentities.Keys.FirstOrDefault(); + } + } + else + { + IdentityType = "None"; + IdentityId = null; + } + } + } +} diff --git a/src/Sql/Sql/Data Sync/Model/AzureSqlSyncGroupSchemaColumnModelV2.cs b/src/Sql/Sql/Data Sync/Model/AzureSqlSyncGroupSchemaColumnModelV2.cs new file mode 100644 index 000000000000..62443a505469 --- /dev/null +++ b/src/Sql/Sql/Data Sync/Model/AzureSqlSyncGroupSchemaColumnModelV2.cs @@ -0,0 +1,70 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using Microsoft.Azure.Management.Sql.DataSyncV2.Models; + +namespace Microsoft.Azure.Commands.Sql.DataSync.Model +{ + /// + /// Represents a the column of a sync group schema table + /// + public class AzureSqlSyncGroupSchemaColumnModelV2 + { + /// + /// The quoted table name + /// + public string QuotedName { get; set; } + + /// + /// Gets or sets data size. + /// + public string DataSize { get; set; } + + /// + /// Gets or sets data type + /// + public string DataType { get; set; } + + /// + /// Construct AzureSqlSyncGroupSchemaColumnModel + /// + public AzureSqlSyncGroupSchemaColumnModelV2() + { + + } + + /// + /// Construct AzureSqlSyncGroupSchemaColumnModel + /// + /// sync group schema column + public AzureSqlSyncGroupSchemaColumnModelV2(SyncGroupSchemaTableColumn column) + { + QuotedName = column != null ? column.QuotedName : null; + DataSize = column != null ? column.DataSize : null; + DataType = column != null ? column.DataType : null; + } + + public SyncGroupSchemaTableColumn ToSyncGroupSchemaColumn() + { + return new SyncGroupSchemaTableColumn + { + DataSize = this.DataSize, + DataType = this.DataType, + QuotedName = this.QuotedName + }; + } + } +} diff --git a/src/Sql/Sql/Data Sync/Model/AzureSqlSyncGroupSchemaModelV2.cs b/src/Sql/Sql/Data Sync/Model/AzureSqlSyncGroupSchemaModelV2.cs new file mode 100644 index 000000000000..5889e207d872 --- /dev/null +++ b/src/Sql/Sql/Data Sync/Model/AzureSqlSyncGroupSchemaModelV2.cs @@ -0,0 +1,79 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using Microsoft.Azure.Management.Sql.DataSyncV2.Models; + +namespace Microsoft.Azure.Commands.Sql.DataSync.Model +{ + /// + /// Represents a the schema of a sync group + /// + public class AzureSqlSyncGroupSchemaModelV2 + { + /// + /// Tables in the database + /// + public IList Tables { get; set; } + + /// + /// Master sync member name + /// + public string MasterSyncMemberName { get; set; } + + /// + /// Construct AzureSqlSyncGroupSchemaModel + /// + public AzureSqlSyncGroupSchemaModelV2() + { + + } + + public AzureSqlSyncGroupSchemaModelV2(SyncGroupSchema schema) + { + if (schema.Tables != null) + { + Tables = new List(); + foreach (var table in schema.Tables) + { + Tables.Add(new AzureSqlSyncGroupSchemaTableModelV2(table)); + } + } + MasterSyncMemberName = schema.MasterSyncMemberName; + } + + /// + /// Convert AzureSqlSyncGroupSchemaModel to SyncGroupSchema + /// + /// The result SyncGroupSchema + public SyncGroupSchema ToSyncGroupSchema() + { + List syncGroupSchemaTable = null; + if (this.Tables != null) + { + syncGroupSchemaTable = new List(); + foreach (var table in this.Tables) + { + syncGroupSchemaTable.Add(table.ToSyncGroupSchemaTable()); + } + } + return new SyncGroupSchema() + { + MasterSyncMemberName = this.MasterSyncMemberName, + Tables = syncGroupSchemaTable + }; + } + } +} diff --git a/src/Sql/Sql/Data Sync/Model/AzureSqlSyncGroupSchemaTableModelV2.cs b/src/Sql/Sql/Data Sync/Model/AzureSqlSyncGroupSchemaTableModelV2.cs new file mode 100644 index 000000000000..dab7fdee2f97 --- /dev/null +++ b/src/Sql/Sql/Data Sync/Model/AzureSqlSyncGroupSchemaTableModelV2.cs @@ -0,0 +1,83 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using Microsoft.Azure.Management.Sql.DataSyncV2.Models; + +namespace Microsoft.Azure.Commands.Sql.DataSync.Model +{ + /// + /// Represents a the table of a sync group schema + /// + public class AzureSqlSyncGroupSchemaTableModelV2 + { + /// + /// Columns in the table + /// + public IList Columns { get; set; } + + /// + /// The quoted table name + /// + public string QuotedName { get; set; } + + /// + /// Construct AzureSqlSyncGroupSchemaTableModel + /// + public AzureSqlSyncGroupSchemaTableModelV2() + { + + } + + /// + /// Construct AzureSqlSyncGroupSchemaTableModel + /// + /// sync group schema table + public AzureSqlSyncGroupSchemaTableModelV2(SyncGroupSchemaTable table) + { + if (table != null && table.Columns != null) + { + Columns = new List(); + foreach (var column in table.Columns) + { + Columns.Add(new AzureSqlSyncGroupSchemaColumnModelV2(column)); + } + } + QuotedName = table != null ? table.QuotedName : null; + } + + /// + /// Convert AzureSqlSyncGroupSchemaTableModel to SyncGroupSchemaTable + /// + /// The result SyncGroupSchemaTable + public SyncGroupSchemaTable ToSyncGroupSchemaTable() + { + List syncGroupSchemaColumns = null; + if (Columns != null) + { + syncGroupSchemaColumns = new List(); + foreach (var column in Columns) + { + syncGroupSchemaColumns.Add(column.ToSyncGroupSchemaColumn()); + } + } + return new SyncGroupSchemaTable() + { + Columns = syncGroupSchemaColumns, + QuotedName = this.QuotedName + }; + } + } +} diff --git a/src/Sql/Sql/Data Sync/Model/AzureSqlSyncIdentityHelper.cs b/src/Sql/Sql/Data Sync/Model/AzureSqlSyncIdentityHelper.cs new file mode 100644 index 000000000000..2c1ca5612602 --- /dev/null +++ b/src/Sql/Sql/Data Sync/Model/AzureSqlSyncIdentityHelper.cs @@ -0,0 +1,45 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Management.Sql.DataSyncV2.Models; +using Microsoft.Azure.Management.Sql.Models; +using System.Collections.Generic; + +namespace Microsoft.Azure.Commands.Sql.DataSync.Model +{ + /// + /// Helper class for constructing DataSyncParticipantIdentity objects. + /// This class is static because it only provides stateless utility methods + /// and should not be instantiated. Can be called for both Sync Group and Sync Member scenarios. + /// + public static class AzureSqlSyncIdentityHelper + { + /// + /// Creates a DataSyncParticipantIdentity for a user-assigned managed identity. + /// + /// The resource ID of the user-assigned managed identity. + /// A DataSyncParticipantIdentity object configured for user-assigned identity. + public static DataSyncParticipantIdentity CreateUserAssignedIdentity(string identityResourceId) + { + return new DataSyncParticipantIdentity + { + Type = "UserAssigned", + UserAssignedIdentities = new Dictionary + { + [identityResourceId] = new DataSyncParticipantUserAssignedIdentity() + } + }; + } + } +} \ No newline at end of file diff --git a/src/Sql/Sql/Data Sync/Model/AzureSqlSyncMemberModelV2.cs b/src/Sql/Sql/Data Sync/Model/AzureSqlSyncMemberModelV2.cs new file mode 100644 index 000000000000..545c4e2cd946 --- /dev/null +++ b/src/Sql/Sql/Data Sync/Model/AzureSqlSyncMemberModelV2.cs @@ -0,0 +1,181 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System.Security; +using Microsoft.Azure.Management.Internal.ResourceManager.Version2018_05_01.Models; +using Microsoft.Azure.Management.Sql.DataSyncV2.Models; +using System.Linq; + +namespace Microsoft.Azure.Commands.Sql.DataSync.Model +{ + /// + /// Represents a sync member object + /// + public class AzureSqlSyncMemberModelV2 + { + /// + /// Gets or sets the resource Id + /// + public string ResourceId { get; set; } + + /// + /// Gets or sets the resource group name + /// + public string ResourceGroupName { get; set; } + + /// + /// Gets or sets the server name + /// + public string ServerName { get; set; } + + /// + /// Gets or sets the database name + /// + public string DatabaseName { get; set; } + + /// + /// Gets or sets the sync group name + /// + public string SyncGroupName { get; set; } + + /// + /// Gets or sets the sync member name + /// + public string SyncMemberName { get; set; } + + /// + /// Gets or sets the sync direction name + /// + public string SyncDirection { get; set; } + + /// + /// Gets or sets the database type of the member database. + /// + public string MemberDatabaseType { get; set; } + + /// + /// Gets or sets the sync agent name + /// + public string SyncAgentId { get; set; } + + /// + /// Gets or sets the id of the SQL server database which is connected by the sync agent + /// + public string SqlServerDatabaseId { get; set; } + + /// + /// Gets or sets the Azure SQL Server Name of the member database + /// + public string MemberServerName { get; set; } + + /// + /// Gets or sets the Azure SQL Server database name of the member database + /// + public string MemberDatabaseName { get; set; } + + /// + /// Gets or sets the user name of Azure SQL database + /// + public string MemberDatabaseUserName { get; set; } + + /// + /// Gets or sets the password of Azure SQL database + /// + public SecureString MemberDatabasePassword { get; set; } + + /// + /// Gets or sets the sync state of a sync member + /// + public string SyncState { get; set; } + + /// + /// Gets or sets the sync member resource Id + /// + public string SyncMemberAzureDatabaseResourceId { get; set; } + + /// + /// Gets or sets whether to use private link connection + /// + public bool? UsePrivateLinkConnection { get; set; } + + /// + /// Gets or sets the identity of the sync member + /// + public DataSyncParticipantIdentity Identity { get; set; } + + // ---- Display helper properties ---- + + /// + /// Gets the identity type of the sync group. + /// Possible values include: 'None', 'SystemAssigned', 'UserAssigned', 'SystemAssignedUserAssigned'. + /// + public string IdentityType { get; private set; } + + /// + /// Gets the Resource ID associated with the sync group EntraID. + /// + public string IdentityId { get; private set; } + + /// + /// Construct AzureSqlSyncMemberModel + /// + public AzureSqlSyncMemberModelV2() + { + + } + + /// + /// Construct AzureSqlSyncMemberModel for Management.Sql.Models.syncMember object + /// + /// Resource group name + /// Server name + /// Database name + /// The name of the sync group + /// sync member object + public AzureSqlSyncMemberModelV2(string resourceGroup, string serverName, string databaseName, string syncGroupName, SyncMember syncMember) + { + ResourceGroupName = resourceGroup; + ServerName = serverName; + DatabaseName = databaseName; + ResourceId = syncMember.Id; + SyncGroupName = syncGroupName; + SyncMemberName = syncMember.Name; + SyncDirection = syncMember.SyncDirection == null ? null : syncMember.SyncDirection.ToString(); + SyncAgentId = syncMember.SyncAgentId; + SqlServerDatabaseId = syncMember.SqlServerDatabaseId == null ? null : syncMember.SqlServerDatabaseId.ToString(); + MemberServerName = syncMember.ServerName; + MemberDatabaseName = syncMember.DatabaseName; + MemberDatabaseUserName = syncMember.UserName; + MemberDatabaseType = syncMember.DatabaseType == null ? null : syncMember.DatabaseType.ToString(); + SyncState = syncMember.SyncState; + UsePrivateLinkConnection = syncMember.UsePrivateLinkConnection; + SyncMemberAzureDatabaseResourceId = syncMember.SyncMemberAzureDatabaseResourceId; + Identity = syncMember.Identity; + if (Identity != null) + { + IdentityType = Identity.Type == null ? null : Identity.Type; + if (Identity.UserAssignedIdentities != null && Identity.UserAssignedIdentities.Count > 0) + { + // Get the first identity resource ID + IdentityId = Identity.UserAssignedIdentities.Keys.FirstOrDefault(); + } + } + else + { + IdentityType = "None"; + IdentityId = null; + } + } + } +} diff --git a/src/Sql/Sql/Data Sync/Services/AzureSqlDataSyncAdapterV2.cs b/src/Sql/Sql/Data Sync/Services/AzureSqlDataSyncAdapterV2.cs new file mode 100644 index 000000000000..66021f861fe7 --- /dev/null +++ b/src/Sql/Sql/Data Sync/Services/AzureSqlDataSyncAdapterV2.cs @@ -0,0 +1,264 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Azure.Commands.Sql.DataSync.Model; +using Microsoft.Azure.Management.Sql.LegacySdk.Models; +using Microsoft.Azure.Commands.Common.Authentication.Abstractions; +using Microsoft.Azure.Commands.Sql.Server.Adapter; + +namespace Microsoft.Azure.Commands.Sql.DataSync.Services +{ + /// + /// Adapter for data sync operations + /// + public class AzureSqlDataSyncAdapterV2 + { + /// + /// Gets or sets the AzureDataSyncCommunicator which has all the needed management clients + /// + private AzureSqlDataSyncCommunicatorV2 Communicator { get; set; } + + /// + /// Gets or sets the Azure profile + /// + public IAzureContext Context { get; set; } + + /// + /// Gets or sets the Azure Subscription + /// + private IAzureSubscription _subscription { get; set; } + + /// + /// Constructs a data sync adapter + /// + /// The current azure profile + public AzureSqlDataSyncAdapterV2(IAzureContext context) + { + Context = context; + _subscription = context?.Subscription; + Communicator = new AzureSqlDataSyncCommunicatorV2(Context); + + } + + /// + /// Gets a sync group by name + /// + /// The resource group the sync group is in + /// The name of the server + /// The name of the database + /// The name of the sync group + /// The sync group object + public AzureSqlSyncGroupModelV2 GetSyncGroup(string resourceGroupName, string serverName, string databaseName, string syncGroupName) + { + var resp = Communicator.GetSyncGroup(resourceGroupName, serverName, databaseName, syncGroupName); + return CreateSyncGroupModelFromResponseV2(resourceGroupName, serverName, databaseName, resp); + } + + /// + /// Gets a list of sync groups + /// + /// The resource group the sync group is in + /// The name of the server + /// The name of the database + /// A list of sync group objects + internal ICollection ListSyncGroups(string resourceGroupName, string serverName, string databaseName) + { + var resp = Communicator.ListSyncGroups(resourceGroupName, serverName, databaseName); + return resp.Select((db) => { + return CreateSyncGroupModelFromResponseV2(resourceGroupName, serverName, databaseName, db); + }).ToList(); + } + + /// + /// Create a sync group + /// + /// AzureSqlSyncGroupModel object + /// The sync database resource id + /// Created AzureSqlSyncGroupModel object + internal AzureSqlSyncGroupModelV2 CreateSyncGroup(AzureSqlSyncGroupModelV2 model, string syncDatabaseId) + { + var createResp = Communicator.CreateSyncGroup(model.ResourceGroupName, model.ServerName, model.DatabaseName, syncDatabaseId, model.SyncGroupName, new Management.Sql.DataSyncV2.Models.SyncGroup() + { + ConflictResolutionPolicy = model.ConflictResolutionPolicy, + Interval = model.IntervalInSeconds, + HubDatabaseUserName = model.HubDatabaseUserName, + HubDatabasePassword = model.HubDatabasePassword == null ? null : AzureSqlServerAdapter.Decrypt(model.HubDatabasePassword), + Schema = model.Schema == null ? null : model.Schema.ToSyncGroupSchema(), + UsePrivateLinkConnection = model.UsePrivateLinkConnection, + Identity = model.Identity + }); + + // Workaround for Rest API return response value incorrect issue. Remove this line after backend fix is deployed + var resp = Communicator.GetSyncGroup(model.ResourceGroupName, model.ServerName, model.DatabaseName, model.SyncGroupName); + return CreateSyncGroupModelFromResponseV2(model.ResourceGroupName, model.ServerName, model.DatabaseName, resp); + } + + /// + /// Update a sync group + /// + /// AzureSqlSyncGroupModel object + /// Updated AzureSqlSyncGroupModel object + internal AzureSqlSyncGroupModelV2 UpdateSyncGroup(AzureSqlSyncGroupModelV2 model) + { + var updateResp = Communicator.UpdateSyncGroup(model.ResourceGroupName, model.ServerName, model.DatabaseName, model.SyncGroupName, new Management.Sql.DataSyncV2.Models.SyncGroup() + { + Interval = model.IntervalInSeconds, + HubDatabaseUserName = model.HubDatabaseUserName, + HubDatabasePassword = model.HubDatabasePassword == null ? null : AzureSqlServerAdapter.Decrypt(model.HubDatabasePassword), + Schema = model.Schema == null ? null : model.Schema.ToSyncGroupSchema(), + UsePrivateLinkConnection = model.UsePrivateLinkConnection, + Identity = model.Identity + }); + + // Workaround for Rest API return response value incorrect issue. Remove this line after backend fix is deployed + var resp = Communicator.GetSyncGroup(model.ResourceGroupName, model.ServerName, model.DatabaseName, model.SyncGroupName); + return CreateSyncGroupModelFromResponseV2(model.ResourceGroupName, model.ServerName, model.DatabaseName, resp); + } + + /// + /// Gets a sync member by name + /// + /// The resource group the sync member is in + /// The name of the server + /// The name of the database + /// The name of the sync group + /// The name of the sync member + /// The sync member object + public AzureSqlSyncMemberModelV2 GetSyncMember(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName) + { + var resp = Communicator.GetSyncMember(resourceGroupName, serverName, databaseName, new SyncMemberGeneralParameters() + { + SyncGroupName = syncGroupName, + SyncMemberName = syncMemberName, + }); + return CreateSyncMemberModelFromResponseV2(resourceGroupName, serverName, databaseName, syncGroupName, resp); + } + + /// + /// Gets a list of sync members + /// + /// The resource group the sync members are in + /// The name of the server + /// The name of the database + /// The name of the sync group + /// A list of sync member objects + internal ICollection ListSyncMembers(string resourceGroupName, string serverName, string databaseName, string syncGroupName) + { + var resp = Communicator.ListSyncMembers(resourceGroupName, serverName, databaseName, syncGroupName); + return resp.Select((db) => + { + return CreateSyncMemberModelFromResponseV2(resourceGroupName, serverName, databaseName, syncGroupName, db); + }).ToList(); + } + + /// + /// Create a sync member + /// + /// AzureSqlSyncMemberModel object + /// The sync agent resource id + /// Created AzureSqlSyncGroupModel object + internal AzureSqlSyncMemberModelV2 CreateSyncMember(AzureSqlSyncMemberModelV2 model, string syncAgentId) + { + Management.Sql.DataSyncV2.Models.SyncMember properties = new Management.Sql.DataSyncV2.Models.SyncMember() + { + SyncDirection = model.SyncDirection, + DatabaseType = model.MemberDatabaseType, + }; + + if (properties.DatabaseType == DatabaseTypeEnum.AzureSqlDatabase.ToString()) + { + properties.DatabaseName = model.MemberDatabaseName; + properties.ServerName = model.MemberServerName; + properties.UserName = model.MemberDatabaseUserName; + properties.Password = model.MemberDatabasePassword == null ? null : AzureSqlServerAdapter.Decrypt(model.MemberDatabasePassword); + properties.UsePrivateLinkConnection = model.UsePrivateLinkConnection; + properties.SyncMemberAzureDatabaseResourceId = model.SyncMemberAzureDatabaseResourceId; + properties.Identity = model.Identity; + } + else + { + properties.SqlServerDatabaseId = model.SqlServerDatabaseId == null ? null : (Guid?)Guid.Parse(model.SqlServerDatabaseId); + properties.SyncAgentId = model.SyncAgentId; + } + var createResp = Communicator.CreateSyncMember(model.ResourceGroupName, model.ServerName, model.DatabaseName, model.SyncGroupName, model.SyncMemberName, syncAgentId, properties); + + // Workaround for Rest API return response value incorrect issue. Remove this line after backend fix is deployed + var resp = Communicator.GetSyncMember(model.ResourceGroupName, model.ServerName, model.DatabaseName, new SyncMemberGeneralParameters() + { + SyncGroupName = model.SyncGroupName, + SyncMemberName = model.SyncMemberName, + }); + return CreateSyncMemberModelFromResponseV2(model.ResourceGroupName, model.ServerName, model.DatabaseName, model.SyncGroupName, resp); + } + + /// + /// Update a sync member + /// + /// AzureSqlSyncMemberModel object + /// Updated AzureSqlSyncGroupModel object + internal AzureSqlSyncMemberModelV2 UpdateSyncMember(AzureSqlSyncMemberModelV2 model) + { + Management.Sql.DataSyncV2.Models.SyncMember properties = new Management.Sql.DataSyncV2.Models.SyncMember() + { + DatabaseType = model.MemberDatabaseType, + DatabaseName = model.MemberDatabaseName, + ServerName = model.MemberServerName, + UserName = model.MemberDatabaseUserName, + Password = model.MemberDatabasePassword == null ? null : AzureSqlServerAdapter.Decrypt(model.MemberDatabasePassword), + UsePrivateLinkConnection = model.UsePrivateLinkConnection, + SyncMemberAzureDatabaseResourceId = model.SyncMemberAzureDatabaseResourceId, + Identity = model.Identity + }; + var updateResp = Communicator.UpdateSyncMember(model.ResourceGroupName, model.ServerName, model.DatabaseName, model.SyncGroupName, model.SyncMemberName, properties); + + // Workaround for Rest API return response value incorrect issue. Remove this line after backend fix is deployed + var resp = Communicator.GetSyncMember(model.ResourceGroupName, model.ServerName, model.DatabaseName, new SyncMemberGeneralParameters() + { + SyncGroupName = model.SyncGroupName, + SyncMemberName = model.SyncMemberName, + }); + return CreateSyncMemberModelFromResponseV2(model.ResourceGroupName, model.ServerName, model.DatabaseName, model.SyncGroupName, resp); + } + + /// + /// Converts the response from the service to a powershell sync group object + /// + /// The resource group the sync group is in + /// The name of the server + /// The name of the database + /// The sync group object from the response + /// The converted model + public static AzureSqlSyncGroupModelV2 CreateSyncGroupModelFromResponseV2(string resourceGroupName, string serverName, string databaseName, Management.Sql.DataSyncV2.Models.SyncGroup syncGroup) + { + return new AzureSqlSyncGroupModelV2(resourceGroupName, serverName, databaseName, syncGroup); + } + + /// + /// Converts the response from the service to a powershell sync member object + /// + /// The resource group the sync member is in + /// The name of the server + /// The name of the database + /// The name of the sync group + /// The sync member object from the response + /// The converted model + public static AzureSqlSyncMemberModelV2 CreateSyncMemberModelFromResponseV2(string resourceGroupName, string serverName, string databaseName, string syncGroupName, Management.Sql.DataSyncV2.Models.SyncMember syncMember) + { + return new AzureSqlSyncMemberModelV2(resourceGroupName, serverName, databaseName, syncGroupName, syncMember); + } + } +} diff --git a/src/Sql/Sql/Data Sync/Services/AzureSqlDataSyncCommunicatorV2.cs b/src/Sql/Sql/Data Sync/Services/AzureSqlDataSyncCommunicatorV2.cs new file mode 100644 index 000000000000..a3431e72c834 --- /dev/null +++ b/src/Sql/Sql/Data Sync/Services/AzureSqlDataSyncCommunicatorV2.cs @@ -0,0 +1,137 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Management.Sql.LegacySdk; +using Microsoft.Azure.Management.Sql.LegacySdk.Models; +using System.Collections.Generic; +using Microsoft.Azure.Management.Sql.DataSyncV2; +using Microsoft.Azure.Commands.Common.Authentication; +using Microsoft.Azure.Commands.Common.Authentication.Abstractions; + +namespace Microsoft.Azure.Commands.Sql.DataSync.Services +{ + /// + /// This class is responsible for all the REST communication with the audit REST endpoints + /// + public class AzureSqlDataSyncCommunicatorV2 + { + /// + /// Gets or set the Azure subscription + /// + private static IAzureSubscription Subscription { get; set; } + + /// + /// Gets or sets the Azure profile + /// + public static IAzureContext Context { get; set; } + + /// + /// Creates a communicator for Azure Sql Data Sync + /// + /// The current Azure profile + public AzureSqlDataSyncCommunicatorV2(IAzureContext context) + { + Context = context; + if (context?.Subscription != Subscription) + { + Subscription = context?.Subscription; + } + } + + /// + /// Create a sync group + /// + public Management.Sql.DataSyncV2.Models.SyncGroup CreateSyncGroup(string resourceGroupName, string serverName, string databaseName, string syncDatabaseId, string syncGroupName, Management.Sql.DataSyncV2.Models.SyncGroup parameters) + { + Management.Sql.DataSyncV2.SqlManagementClient client = GetCurrentSqlClient(); + parameters.SyncDatabaseId = syncDatabaseId == null ? null : string.Format("/subscriptions/{0}/{1}", Subscription.Id, syncDatabaseId); + return client.SyncGroups.CreateOrUpdate(resourceGroupName, serverName, databaseName, syncGroupName, parameters); + } + + /// + /// Update a sync group + /// + public Management.Sql.DataSyncV2.Models.SyncGroup UpdateSyncGroup(string resourceGroupName, string serverName, string databaseName, string syncGroupName, Management.Sql.DataSyncV2.Models.SyncGroup parameters) + { + return GetCurrentSqlClient().SyncGroups.Update(resourceGroupName, serverName, databaseName, syncGroupName, parameters); + } + + /// + /// Get a sync group + /// + public Management.Sql.DataSyncV2.Models.SyncGroup GetSyncGroup(string resourceGroupName, string serverName, string databaseName, string syncGroupName) + { + return GetCurrentSqlClient().SyncGroups.Get(resourceGroupName, serverName, databaseName, syncGroupName); + } + + /// + /// List all sync groups + /// + public IEnumerable ListSyncGroups(string resourceGroupName, string serverName, string databaseName) + { + return GetCurrentSqlClient().SyncGroups.ListByDatabase(resourceGroupName, serverName, databaseName); + } + + + /// + /// Get a sync group + /// + public Management.Sql.DataSyncV2.Models.SyncMember GetSyncMember(string resourceGroupName, string serverName, string databaseName, SyncMemberGeneralParameters parameters) + { + return GetCurrentSqlClient().SyncMembers.Get(resourceGroupName, serverName, databaseName, parameters.SyncGroupName, parameters.SyncMemberName); + } + + /// + /// List all sync members + /// + public IEnumerable ListSyncMembers(string resourceGroupName, string serverName, string databaseName, string syncGroupName) + { + return GetCurrentSqlClient().SyncMembers.ListBySyncGroup(resourceGroupName, serverName, databaseName, syncGroupName); + } + + /// + /// Create a new sync member + /// + public Management.Sql.DataSyncV2.Models.SyncMember CreateSyncMember(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, string syncAgentId, Management.Sql.DataSyncV2.Models.SyncMember parameters) + { + Management.Sql.DataSyncV2.SqlManagementClient client = GetCurrentSqlClient(); + if (syncAgentId != null) + { + parameters.SyncAgentId = string.Format("/subscriptions/{0}/{1}", Subscription.Id, syncAgentId); + } + return client.SyncMembers.CreateOrUpdate(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters); + } + + /// + /// Update an existing sync member + /// + public Management.Sql.DataSyncV2.Models.SyncMember UpdateSyncMember(string resourceGroupName, string serverName, string databaseName, string syncGroupName, string syncMemberName, Management.Sql.DataSyncV2.Models.SyncMember parameters) + { + return GetCurrentSqlClient().SyncMembers.Update(resourceGroupName, serverName, databaseName, syncGroupName, syncMemberName, parameters); + } + + /// + /// Retrieve the SQL Management client for the currently selected subscription, adding the session and request + /// id tracing headers for the current cmdlet invocation. + /// + /// The SQL Management client for the currently selected subscription. + public static Management.Sql.DataSyncV2.SqlManagementClient GetCurrentSqlClient() + { + // Get the SQL management client for the current subscription + // Note: client is not cached in static field because that causes ObjectDisposedException in functional tests. + var sqlClient = AzureSession.Instance.ClientFactory.CreateArmClient(Context, AzureEnvironment.Endpoint.ResourceManager); + return sqlClient; + } + } +} \ No newline at end of file diff --git a/src/Sql/Sql/Properties/Resources.Designer.cs b/src/Sql/Sql/Properties/Resources.Designer.cs index 697af13b41f4..8aeab0be521e 100644 --- a/src/Sql/Sql/Properties/Resources.Designer.cs +++ b/src/Sql/Sql/Properties/Resources.Designer.cs @@ -402,6 +402,15 @@ internal static string CreateAzureSqlInstanceServerTrustCertificateWarning { } } + /// + /// Looks up a localized string similar to DatabaseCredentials (username/password) must be provided when HubDatabaseAuthenticationType is 'password'.. + /// + internal static string DatabaseCredentialRequired { + get { + return ResourceManager.GetString("DatabaseCredentialRequired", resourceCulture); + } + } + /// /// Looks up a localized string similar to Database with name: '{0}' already exists in server '{1}'.. /// @@ -645,6 +654,15 @@ internal static string ForwardMigrationWithGeoDRInfo { } } + /// + /// Looks up a localized string similar to IdentityId must be provided when HubDatabaseAuthenticationType is 'userAssigned'.. + /// + internal static string IdentityIdRequired { + get { + return ResourceManager.GetString("IdentityIdRequired", resourceCulture); + } + } + /// /// Looks up a localized string similar to The Active Directory Group '{0}' is not security enabled. Only Azure Active Directory Security Enabled Groups are supported.. /// @@ -663,6 +681,15 @@ internal static string InvalidBlobStorageSasUri { } } + /// + /// Looks up a localized string similar to Invalid DatabaseAuthenticationType. Supported authentication types are 'userAssigned' and 'Password'. + /// + internal static string InvalidDatabaseAuthenticationType { + get { + return ResourceManager.GetString("InvalidDatabaseAuthenticationType", resourceCulture); + } + } + /// /// Looks up a localized string similar to Cannot use the None option with other event types.. /// diff --git a/src/Sql/Sql/Properties/Resources.resx b/src/Sql/Sql/Properties/Resources.resx index 694f54c5a582..d24b455d0480 100644 --- a/src/Sql/Sql/Properties/Resources.resx +++ b/src/Sql/Sql/Properties/Resources.resx @@ -766,4 +766,13 @@ Changing the service tier to Hyperscale also converts the geo-secondary replica to Hyperscale. For more information, see https://go.microsoft.com/fwlink/?linkid=2314103 + + IdentityId must be provided when HubDatabaseAuthenticationType is 'userAssigned'. + + + DatabaseCredentials (username/password) must be provided when HubDatabaseAuthenticationType is 'password'. + + + Invalid DatabaseAuthenticationType. Supported authentication types are 'userAssigned' and 'Password' + \ No newline at end of file diff --git a/src/Sql/Sql/Sql.format.ps1xml b/src/Sql/Sql/Sql.format.ps1xml index 02a11fd7420c..74dc1fca07fc 100644 --- a/src/Sql/Sql/Sql.format.ps1xml +++ b/src/Sql/Sql/Sql.format.ps1xml @@ -2023,6 +2023,222 @@ + + + Microsoft.Azure.Commands.Sql.DataSync.Model.AzureSqlSyncGroupModel + + Microsoft.Azure.Commands.Sql.DataSync.Model.AzureSqlSyncGroupModel + + + + + + 30 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ResourceId + + + ResourceGroupName + + + ServerName + + + DatabaseName + + + SyncGroupName + + + SyncDatabaseId + + + IntervalInSeconds + + + HubDatabaseUserName + + + ConflictResolutionPolicy + + + SyncState + + + LastSyncTime + + + Schema + + + IdentityType + + + IdentityId + + + + + + + + Microsoft.Azure.Commands.Sql.DataSync.Model.AzureSqlSyncMemberModel + + Microsoft.Azure.Commands.Sql.DataSync.Model.AzureSqlSyncMemberModel + + + + + + 30 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ResourceId + + + ResourceGroupName + + + ServerName + + + DatabaseName + + + SyncGroupName + + + SyncMemberName + + + SyncDirection + + + MemberDatabaseType + + + SyncAgentId + + + SqlServerDatabaseId + + + MemberServerName + + + MemberDatabaseName + + + MemberDatabaseUserName + + + SyncState + + + IdentityType + + + IdentityId + + + + + diff --git a/src/Sql/Sql/help/New-AzSqlSyncGroupV2.md b/src/Sql/Sql/help/New-AzSqlSyncGroupV2.md new file mode 100644 index 000000000000..9d7be43289ce --- /dev/null +++ b/src/Sql/Sql/help/New-AzSqlSyncGroupV2.md @@ -0,0 +1,371 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Sql.dll-Help.xml +Module Name: Az.Sql +online version: +schema: 2.0.0 +--- + +# New-AzSqlSyncGroupV2 + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +New-AzSqlSyncGroupV2 [-Name] -SyncDatabaseName -SyncDatabaseServerName + -SyncDatabaseResourceGroupName [-IntervalInSeconds ] [-DatabaseCredential ] + [-ConflictResolutionPolicy ] [-SchemaFile ] [-UsePrivateLinkConnection] + [-HubDatabaseAuthenticationType ] [-IdentityId ] [-ServerName] + [-DatabaseName] [-ResourceGroupName] [-DefaultProfile ] [-WhatIf] + [-Confirm] [] +``` + +## DESCRIPTION +The **New-AzSqlSyncGroupV2** cmdlet creates an Azure SQL Database Sync Group with the specified parameters. + +### Example 1: Create a sync group for an Azure SQL Database using user-assigned managed identity authentication + +This command creates a sync group using a **user-assigned managed identity** to authenticate to the hub database. This allows secure, passwordless authentication by referencing the Azure resource ID of the identity. + +```powershell +New-AzSqlSyncGroupV2 -ResourceGroupName "ResourceGroup02" -ServerName "Server02" -DatabaseName "Database02" -Name "SyncGroup02" ` +-ConflictResolutionPolicy "HubWin" -IntervalInSeconds -1 ` +-SyncDatabaseServerName "Server02" -SyncDatabaseName "Database02" ` +-SyncDatabaseResourceGroupName "syncDatabaseResourceGroup02" ` +-HubDatabaseAuthenticationType "userAssigned" ` +-IdentityId "/subscriptions/{subscriptionId}/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi" -Schema ".\schema.json" | Format-List +``` + +```output +ResourceId : /subscriptions/{subscriptionId}/resourceGroups/{syncDatabaseResourceGroup02}/providers/Microsoft.Sql/servers/{Server02}/databases/{Database02}/syncGroups/{SyncGroup02} +ResourceGroupName : ResourceGroup02 +ServerName : Server02 +DatabaseName : Database02 +SyncGroupName : SyncGroup02 +SyncDatabaseId : /subscriptions/{subscriptionId}/resourceGroups/{syncDatabaseResourceGroup02}/providers/Microsoft.Sql/servers/{Server02}/databases/{Database02} +IntervalInSeconds : -1 +ConflictResolutionPolicy : HubWin +Identity.Type : UserAssigned +UserAssignedIdentities : { + "/subscriptions/{subscriptionId}/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi": { + "clientId": "{clientId}", + "principalId": "{principalId}" + } + } +SyncState : NotReady +LastSyncTime : 1/1/0001 12:00:00 AM +Schema : +``` + +This command creates a sync group for an Azure SQL Database. "schema.json" is a file in the local disk. It contains the schema payload in json format. An example of the schema json is: +{"Tables": [{"Columns": [{"QuotedName": "b3ee3a7f-7614-4644-ad07-afa832620b4bManualTestsm4column1"}, {"QuotedName": "b3ee3a7f-7614-4644-ad07-afa832620b4bManualTestsm4column2"}], "QuotedName": "MayQuotedTable1"}, +{"Columns": [{"QuotedName": "b3ee3a7f-7614-4644-ad07-afa832620b4bManualTestsm4column1"}, {"QuotedName": "b3ee3a7f-7614-4644-ad07-afa832620b4bManualTestsm4column2"}], "QuotedName": "MayQuotedTable2"}], +"MasterSyncMemberName": null +} + +### Example 2: Create a sync group for an Azure SQL Database using SQL Authentication. +```powershell +$credential = Get-Credential +New-AzSqlSyncGroupV2 -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01" -Name "SyncGroup01" -ConflictResolutionPolicy "HubWin" ` +-DatabaseCredential $credential -IntervalInSeconds 100 -SyncDatabaseServerName "syncDatabaseServer01" -SyncDatabaseName "syncDatabaseName01" ` +-SyncDatabaseResourceGroupName "syncDatabaseResourceGroup01" -Schema ".\schema.json" | Format-List +``` + +```output +ResourceId : /subscriptions/{subscriptionId}/resourceGroups/{ResourceGroup01}/servers/{Server01}/databases/{Database01}/syncGroups/{SyncGroup01} +ResourceGroupName : ResourceGroup01 +ServerName : Server01 +DatabaseName : Database01 +SyncGroupName : SyncGroup01 +SyncDatabaseId : subscriptions/{subscriptionId}/resourceGroups/{syncDatabaseResourceGroup01}/servers/{syncDatabaseServer01}/databases/{syncDatabaseName01} +IntervalInSeconds : 100 +ConflictResolutionPolicy: : HubWin +HubDatabaseUserName : myAccount +HubDatabasePassword : +SyncState : NotReady +LastSyncTime : 1/1/0001 12:00:00 AM +Schema : +``` + +## PARAMETERS + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ConflictResolutionPolicy +The policy of resolving conflicts between hub and member database in the sync group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: HubWin, MemberWin + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DatabaseCredential +The SQL authentication credential of the hub database. + +```yaml +Type: PSCredential +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DatabaseName +SQL Database name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -HubDatabaseAuthenticationType +The Database Authentication type of the hub database. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: password, userAssigned + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -IdentityId +The identity ID of the hub database in case of UAMI Authentication. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -IntervalInSeconds +The frequency (in seconds) of doing data synchronization. +Default is -1, which means the auto synchronization is not enabled. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +The sync group name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: SyncGroupName + +Required: True +Position: 3 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ResourceGroupName +The name of the resource group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -SchemaFile +The path of the schema file. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ServerName +SQL Database server name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -SyncDatabaseName +The database used to store sync related metadata. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SyncDatabaseResourceGroupName +The resource group the sync metadata database belongs to. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SyncDatabaseServerName +The server on which the sync metadata database is hosted. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UsePrivateLinkConnection +Use a private link connection when connecting to the hub of this sync group. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String + +## OUTPUTS + +### Microsoft.Azure.Commands.Sql.DataSync.Model.AzureSqlSyncGroupModelV2 + +## NOTES + +## RELATED LINKS + +[Update-AzSqlSyncGroupV2](./Update-AzSqlSyncGroupV2.md) + +[Remove-AzSqlSyncGroup](./Remove-AzSqlSyncGroup.md) + +[Get-AzSqlSyncGroup](./Get-AzSqlSyncGroup.md) diff --git a/src/Sql/Sql/help/New-AzSqlSyncMemberV2.md b/src/Sql/Sql/help/New-AzSqlSyncMemberV2.md new file mode 100644 index 000000000000..6a4d1b792f69 --- /dev/null +++ b/src/Sql/Sql/help/New-AzSqlSyncMemberV2.md @@ -0,0 +1,467 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Sql.dll-Help.xml +Module Name: Az.Sql +online version: +schema: 2.0.0 +--- + +# New-AzSqlSyncMemberV2 + +## SYNOPSIS +Creates an Azure SQL Database Sync Member. + +## SYNTAX + +### AzureSqlDatabase (Default) +``` +New-AzSqlSyncMemberV2 -Name -MemberDatabaseType -MemberServerName + -MemberDatabaseName -MemberDatabaseCredential [-SyncDirection ] + [-UsePrivateLinkConnection] [-SyncMemberAzureDatabaseResourceId ] + [-MemberDatabaseAuthenticationType ] [-IdentityId ] [-SyncGroupName] + [-ServerName] [-DatabaseName] [-ResourceGroupName] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### OnPremisesDatabaseSyncAgentComponent +``` +New-AzSqlSyncMemberV2 -Name -MemberDatabaseType -SyncAgentResourceGroupName + -SyncAgentServerName -SyncAgentName -SqlServerDatabaseId [-SyncDirection ] + [-UsePrivateLinkConnection] [-SyncMemberAzureDatabaseResourceId ] + [-MemberDatabaseAuthenticationType ] [-IdentityId ] [-SyncGroupName] + [-ServerName] [-DatabaseName] [-ResourceGroupName] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### OnPremisesDatabaseSyncAgentResourceID +``` +New-AzSqlSyncMemberV2 -Name -MemberDatabaseType -SqlServerDatabaseId + -SyncAgentResourceID [-SyncDirection ] [-UsePrivateLinkConnection] + [-SyncMemberAzureDatabaseResourceId ] [-MemberDatabaseAuthenticationType ] + [-IdentityId ] [-SyncGroupName] [-ServerName] [-DatabaseName] + [-ResourceGroupName] [-DefaultProfile ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +The **New-AzSqlSyncMember** cmdlet creates an Azure SQL Database Sync Member. + +## EXAMPLES + +### Example 1: Create a sync member for an Azure SQL database using user managed identity authentication. +```powershell +$credential = Get-Credential +New-AzSqlSyncMemberV2 -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01" -SyncGroupName "SyncGroup01" -Name "SyncMember01" -SyncDirection "OneWayMemberToHub" ` +-MemberDatabaseType "AzureSqlDatabase" -MemberServerName "memberServer01.full.dns.name" -MemberDatabaseName "memberDatabase01" -HubDatabaseAuthenticationType "userAssigned" ` +-IdentityId "/subscriptions/{subscriptionId}/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi" -Schema ".\schema.json" | Format-List +``` + +```output +ResourceId : subscriptions/{subscriptionId}/resourceGroups/{ResourceGroup01}/servers/{Server01}/databases/{Database01}/syncGroups/{SyncGroup01}/syncMembers/{SyncMember01} +ResourceGroupName : ResourceGroup01 +ServerName : Server01 +DatabaseName : Database01 +SyncGroupName : SyncGroup01 +SyncMemberName : SyncMember01 +SyncDirection : OneWayMemberToHub +MemberDatabaseType: : AzureSqlDatabase +SyncAgentId : +SqlServerDatabaseId : +MemberServerName : memberServer01.full.dns.name +MemberDatabaseName : memberDatabase01 +MemberDatabasePassword : +SyncState : UnProvisioned +Identity.Type : UserAssigned +UserAssignedIdentities : { + "/subscriptions/{subscriptionId}/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi": { + "clientId": "{clientId}", + "principalId": "{principalId}" + } + } +``` + +This command creates a sync member for an Azure SQL database. + +### Example 2: Create a sync member for an on-premises SQL Server database +```powershell +$credential = Get-Credential +New-AzSqlSyncMemberV2 -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01" -SyncGroupName "SyncGroup01" -Name "SyncMember01" -SyncDirection "OneWayMemberToHub" ` +-MemberDatabaseType "SqlServerDatabase" -SqlServerDatabaseId "dbId" -syncAgentResourceGroupName "syncAgentResourceGroupName" -syncAgentServerName "syncAgentServerName" ` +-syncAgentDatabaseName "syncAgentDatabaseName" -syncAgentName "agentName" | Format-List +``` + +```output +ResourceId : /subscriptions/{subscriptionId}/resourceGroups/{ResourceGroup01}/servers/{Server01}/databases/{Database01}/syncGroups/{SyncGroup01}/syncMembers/{SyncMember01} +ResourceGroupName : ResourceGroup01 +ServerName : Server01 +DatabaseName : Database01 +SyncGroupName : SyncGroup01 +SyncMemberName : SyncMember01 +SyncDirection : OneWayMemberToHub +MemberDatabaseType: : AzureSqlDatabase +SyncAgentId : /subscriptions/{subscriptionId}/resourceGroups/{syncAgentResourceGroupName}/servers/{syncAgentServerName}/syncAgents/{syncAgentId} +SqlServerDatabaseId : dbId +MemberServerName : +MemberDatabaseName : +MemberDatabaseUserName : myAccount +MemberDatabasePassword : +SyncState : UnProvisioned +``` + +This command creates a sync member for an on-premises SQL database. + +## PARAMETERS + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DatabaseName +SQL Database name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -IdentityId +The identity ID of the sync member DB in case of UAMI Authentication + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MemberDatabaseAuthenticationType +The Database Authentication type of the sync member database. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: password, userAssigned + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MemberDatabaseCredential +The credential (username and password) of the Azure SQL Database. + +```yaml +Type: PSCredential +Parameter Sets: AzureSqlDatabase +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MemberDatabaseName +The Azure SQL Database name of the member database. + +```yaml +Type: String +Parameter Sets: AzureSqlDatabase +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MemberDatabaseType +The database type of the member database. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: SqlServerDatabase, AzureSqlDatabase + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -MemberServerName +The Azure SQL Server Name of the member database. + +```yaml +Type: String +Parameter Sets: AzureSqlDatabase +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +The sync member name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: SyncMemberName + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ResourceGroupName +The name of the resource group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ServerName +SQL Database server name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -SqlServerDatabaseId +The id of the SQL server database which is connected by the sync agent. + +```yaml +Type: String +Parameter Sets: OnPremisesDatabaseSyncAgentComponent, OnPremisesDatabaseSyncAgentResourceID +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SyncAgentName +The name of the sync agent. + +```yaml +Type: String +Parameter Sets: OnPremisesDatabaseSyncAgentComponent +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SyncAgentResourceGroupName +The name of the resource group where the sync agent is under. + +```yaml +Type: String +Parameter Sets: OnPremisesDatabaseSyncAgentComponent +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SyncAgentResourceID +The resource ID of the sync agent. + +```yaml +Type: String +Parameter Sets: OnPremisesDatabaseSyncAgentResourceID +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SyncAgentServerName +The name of the Azure SQL Server where the sync agent is under. + +```yaml +Type: String +Parameter Sets: OnPremisesDatabaseSyncAgentComponent +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SyncDirection +The sync direction of this sync member. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: Bidirectional, OneWayMemberToHub, OneWayHubToMember + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SyncGroupName +The sync group name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -SyncMemberAzureDatabaseResourceId +The resource ID for the sync member database, used if UsePrivateLinkConnection is set to true. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UsePrivateLinkConnection +Use a private link connection when connecting to this sync member. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String + +## OUTPUTS + +### Microsoft.Azure.Commands.Sql.DataSync.Model.AzureSqlSyncMemberModelV2 + +## NOTES + +## RELATED LINKS + +[Get-AzSqlSyncMember](./Get-AzSqlSyncMember.md) + +[Update-AzSqlSyncMemberV2](./Update-AzSqlSyncMemberV2.md) + +[Remove-AzSqlSyncMember](./Remove-AzSqlSyncMember.md) diff --git a/src/Sql/Sql/help/Update-AzSqlSyncGroupV2.md b/src/Sql/Sql/help/Update-AzSqlSyncGroupV2.md new file mode 100644 index 000000000000..268c1720d628 --- /dev/null +++ b/src/Sql/Sql/help/Update-AzSqlSyncGroupV2.md @@ -0,0 +1,277 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Sql.dll-Help.xml +Module Name: Az.Sql +online version: +schema: 2.0.0 +--- + +# Update-AzSqlSyncGroupV2 + +## SYNOPSIS +Updates an Azure SQL Database Sync Group. + +## SYNTAX + +``` +Update-AzSqlSyncGroupV2 [-Name] [-IntervalInSeconds ] [-DatabaseCredential ] + [-SchemaFile ] [-UsePrivateLinkConnection ] [-HubDatabaseAuthenticationType ] + [-IdentityId ] [-ServerName] [-DatabaseName] [-ResourceGroupName] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +The **Update-AzSqlSyncGroupV2** cmdlet modifies properties of an Azure SQL Database Sync Group. + +## EXAMPLES + +### Example 1: Update a sync group for an Azure SQL Database. +```powershell +$credential = Get-Credential +Update-AzSqlSyncGroupV2 -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01" -Name "SyncGroup01" ` +-HubDatabaseAuthenticationType "userAssigned" ` +-IdentityId "/subscriptions/{subscriptionId}/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi" -IntervalInSeconds 100 -Schema ".\schema.json" | Format-List +``` + +```output +ResourceId : /subscriptions/{subscriptionId}/resourceGroups/{ResourceGroup01}/servers/{Server01}/databases/{Database01}/syncGroups/{SyncGroup01} +ResourceGroupName : ResourceGroup01 +ServerName : Server01 +DatabaseName : Database01 +SyncGroupName : SyncGroup01 +SyncDatabaseId : subscriptions/{subscriptionId}/resourceGroups/{syncDatabaseResourceGroup01}/servers/{syncDatabaseServer01}/databases/{syncDatabaseName01} +IntervalInSeconds : 100 +ConflictResolutionPolicy: : HubWin +SyncState : NotReady +LastSyncTime : 1/1/0001 12:00:00 AM +Schema : +Identity.Type : UserAssigned +UserAssignedIdentities : { + "/subscriptions/{subscriptionId}/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi": { + "clientId": "{clientId}", + "principalId": "{principalId}" + } + } +``` + +{{ Add example description here }} + +## PARAMETERS + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DatabaseCredential +The SQL authentication credential of the hub database. + +```yaml +Type: PSCredential +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DatabaseName +SQL Database name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -HubDatabaseAuthenticationType +The Database Authentication type of the hub database. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: password, userAssigned + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -IdentityId +The identity ID of the hub database in case of UAMI Authentication + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -IntervalInSeconds +The frequency (in seconds) of doing data synchronization. +Default is -1, which means the auto synchronization is not enabled. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +The sync group name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: SyncGroupName + +Required: True +Position: 3 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ResourceGroupName +The name of the resource group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -SchemaFile +The path of the schema file. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ServerName +SQL Database server name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -UsePrivateLinkConnection +Whether to use a private link connection when connecting to the hub of this sync group. + +```yaml +Type: Boolean +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String + +## OUTPUTS + +### Microsoft.Azure.Commands.Sql.DataSync.Model.AzureSqlSyncGroupModelV2 + +## NOTES + +## RELATED LINKS + +[New-AzSqlSyncGroupV2](./New-AzSqlSyncGroupV2.md) + +[Remove-AzSqlSyncGroup](./Remove-AzSqlSyncGroup.md) + +[Get-AzSqlSyncGroup](./Get-AzSqlSyncGroup.md) \ No newline at end of file diff --git a/src/Sql/Sql/help/Update-AzSqlSyncMemberV2.md b/src/Sql/Sql/help/Update-AzSqlSyncMemberV2.md new file mode 100644 index 000000000000..682988f2b777 --- /dev/null +++ b/src/Sql/Sql/help/Update-AzSqlSyncMemberV2.md @@ -0,0 +1,278 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Sql.dll-Help.xml +Module Name: Az.Sql +online version: +schema: 2.0.0 +--- + +# Update-AzSqlSyncMemberV2 + +## SYNOPSIS +Updates an Azure SQL Database Sync Member. + +## SYNTAX + +``` +Update-AzSqlSyncMemberV2 -Name [-MemberDatabaseCredential ] + [-UsePrivateLinkConnection ] [-SyncMemberAzureDatabaseResourceId ] + [-MemberDatabaseAuthenticationType ] [-IdentityId ] [-SyncGroupName] + [-ServerName] [-DatabaseName] [-ResourceGroupName] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +The **Update-AzSqlSyncGroupV2** cmdlet modifies properties of an Azure SQL Database Sync Member. + +## EXAMPLES + +### Example 1 +```powershell +$credential = Get-Credential +Update-AzSqlSyncMemberV2 -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -DatabaseName "Database01" -SyncGroupName "SyncGroup01" -Name "SyncMember01" ` +-HubDatabaseAuthenticationType "userAssigned" ` +-IdentityId "/subscriptions/{subscriptionId}/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi" -IntervalInSeconds 100 -Schema ".\schema.json" | Format-List +``` + +```output +ResourceId : subscriptions/{subscriptionId}/resourceGroups/{ResourceGroup01}/servers/{Server01}/databases/{Database01}/syncGroups/{SyncGroup01}/syncMembers/{SyncMember01} +ResourceGroupName : ResourceGroup01 +ServerName : Server01 +DatabaseName : Database01 +SyncGroupName : SyncGroup01 +SyncMemberName : SyncMember01 +SyncDirection : OneWayMemberToHub +MemberDatabaseType: : AzureSqlDatabase +SyncAgentId : +SqlServerDatabaseId : +MemberServerName : memberServer01.full.dns.name +MemberDatabaseName : memberDatabase01 +MemberDatabasePassword : +SyncState : Good +Identity.Type : UserAssigned +UserAssignedIdentities : { + "/subscriptions/{subscriptionId}/resourceGroups/group1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi": { + "clientId": "{clientId}", + "principalId": "{principalId}" + } + } +``` + +## PARAMETERS + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DatabaseName +SQL Database name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 2 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -IdentityId +The identity ID of the sync member DB in case of UAMI Authentication + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MemberDatabaseAuthenticationType +The Database Authentication type of the sync member database. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: password, userAssigned + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -MemberDatabaseCredential +The credential (username and password) of the Azure SQL Database. + +```yaml +Type: PSCredential +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +The sync member name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: SyncMemberName + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ResourceGroupName +The name of the resource group. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 0 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ServerName +SQL Database server name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -SyncGroupName +The sync group name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: True +Position: 3 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -SyncMemberAzureDatabaseResourceId +The resource ID for the sync member database, used if UsePrivateLinkConnection is set to true. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UsePrivateLinkConnection +Whether to use private link when connecting to this sync member. + +```yaml +Type: Boolean +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String + +## OUTPUTS + +### Microsoft.Azure.Commands.Sql.DataSync.Model.AzureSqlSyncMemberModelV2 + +## NOTES + +## RELATED LINKS + +[New-AzSqlSyncMemberV2](./New-AzSqlSyncMemberV2.md) + +[Get-AzSqlSyncMember](./Get-AzSqlSyncMember.md) + +[Remove-AzSqlSyncMember](./Remove-AzSqlSyncMember.md)