From 8fc5e2f6f3c07382b9a6792798d5cb251acb8ffd Mon Sep 17 00:00:00 2001 From: adxsdknet Date: Thu, 23 May 2019 01:01:17 +0000 Subject: [PATCH] .NET SDK Resource Provider:'DataMigration' REST Spec PR 'https://github.com/Azure/azure-rest-api-specs/pull/5801' REST Spec PR Author 'huang91shu' REST Spec PR Last commit --- .../Generated/DataMigrationServiceClient.cs | 6 - .../Generated/IDataMigrationServiceClient.cs | 5 - .../Generated/IServiceTasksOperations.cs | 124 ---- .../SdkInfo_DataMigrationManagementClient.cs | 1 - .../Generated/ServiceTasksOperations.cs | 640 ------------------ .../ServiceTasksOperationsExtensions.cs | 189 ------ 6 files changed, 965 deletions(-) delete mode 100644 src/SDKs/DataMigration/Management.DataMigration/Generated/IServiceTasksOperations.cs delete mode 100644 src/SDKs/DataMigration/Management.DataMigration/Generated/ServiceTasksOperations.cs delete mode 100644 src/SDKs/DataMigration/Management.DataMigration/Generated/ServiceTasksOperationsExtensions.cs diff --git a/src/SDKs/DataMigration/Management.DataMigration/Generated/DataMigrationServiceClient.cs b/src/SDKs/DataMigration/Management.DataMigration/Generated/DataMigrationServiceClient.cs index 7f7a66d375593..0c564f21a37c5 100644 --- a/src/SDKs/DataMigration/Management.DataMigration/Generated/DataMigrationServiceClient.cs +++ b/src/SDKs/DataMigration/Management.DataMigration/Generated/DataMigrationServiceClient.cs @@ -89,11 +89,6 @@ public partial class DataMigrationServiceClient : ServiceClient public virtual ITasksOperations Tasks { get; private set; } - /// - /// Gets the IServiceTasksOperations. - /// - public virtual IServiceTasksOperations ServiceTasks { get; private set; } - /// /// Gets the IProjectsOperations. /// @@ -358,7 +353,6 @@ private void Initialize() ResourceSkus = new ResourceSkusOperations(this); Services = new ServicesOperations(this); Tasks = new TasksOperations(this); - ServiceTasks = new ServiceTasksOperations(this); Projects = new ProjectsOperations(this); Usages = new UsagesOperations(this); Operations = new Operations(this); diff --git a/src/SDKs/DataMigration/Management.DataMigration/Generated/IDataMigrationServiceClient.cs b/src/SDKs/DataMigration/Management.DataMigration/Generated/IDataMigrationServiceClient.cs index a9f68c7a86fba..fb363fd03523b 100644 --- a/src/SDKs/DataMigration/Management.DataMigration/Generated/IDataMigrationServiceClient.cs +++ b/src/SDKs/DataMigration/Management.DataMigration/Generated/IDataMigrationServiceClient.cs @@ -84,11 +84,6 @@ public partial interface IDataMigrationServiceClient : System.IDisposable /// ITasksOperations Tasks { get; } - /// - /// Gets the IServiceTasksOperations. - /// - IServiceTasksOperations ServiceTasks { get; } - /// /// Gets the IProjectsOperations. /// diff --git a/src/SDKs/DataMigration/Management.DataMigration/Generated/IServiceTasksOperations.cs b/src/SDKs/DataMigration/Management.DataMigration/Generated/IServiceTasksOperations.cs deleted file mode 100644 index 421fc0ae7f6a4..0000000000000 --- a/src/SDKs/DataMigration/Management.DataMigration/Generated/IServiceTasksOperations.cs +++ /dev/null @@ -1,124 +0,0 @@ -// -// 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.DataMigration -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Collections; - using System.Collections.Generic; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ServiceTasksOperations operations. - /// - public partial interface IServiceTasksOperations - { - /// - /// Get service level tasks for a service - /// - /// - /// The services resource is the top-level resource that represents the - /// Database Migration Service. This method returns a list of service - /// level tasks owned by a service resource. Some tasks may have a - /// status of Unknown, which indicates that an error occurred while - /// querying the status of that task. - /// - /// - /// Name of the resource group - /// - /// - /// Name of the service - /// - /// - /// Filter tasks by task type - /// - /// - /// 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 - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListWithHttpMessagesAsync(string groupName, string serviceName, string taskType = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Cancel a service task - /// - /// - /// The service tasks resource is a nested, proxy-only resource - /// representing work performed by a DMS instance. This method cancels - /// a service task if it's currently queued or running. - /// - /// - /// Name of the resource group - /// - /// - /// Name of the service - /// - /// - /// Name of the Task - /// - /// - /// 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 - /// - /// - /// Thrown when a required parameter is null - /// - Task> CancelWithHttpMessagesAsync(string groupName, string serviceName, string taskName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - /// - /// Get service level tasks for a service - /// - /// - /// The services resource is the top-level resource that represents the - /// Database Migration Service. This method returns a list of service - /// level tasks owned by a service resource. Some tasks may have a - /// status of Unknown, which indicates that an error occurred while - /// querying the status of that task. - /// - /// - /// 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 - /// - /// - /// Thrown when a required parameter is null - /// - Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); - } -} diff --git a/src/SDKs/DataMigration/Management.DataMigration/Generated/SdkInfo_DataMigrationManagementClient.cs b/src/SDKs/DataMigration/Management.DataMigration/Generated/SdkInfo_DataMigrationManagementClient.cs index 137ba383fd2cb..13adbae4636bc 100644 --- a/src/SDKs/DataMigration/Management.DataMigration/Generated/SdkInfo_DataMigrationManagementClient.cs +++ b/src/SDKs/DataMigration/Management.DataMigration/Generated/SdkInfo_DataMigrationManagementClient.cs @@ -23,7 +23,6 @@ public static IEnumerable> ApiInfo_DataMigrationMa new Tuple("DataMigration", "Operations", "2018-07-15-preview"), new Tuple("DataMigration", "Projects", "2018-07-15-preview"), new Tuple("DataMigration", "ResourceSkus", "2018-07-15-preview"), - new Tuple("DataMigration", "ServiceTasks", "2018-07-15-preview"), new Tuple("DataMigration", "Services", "2018-07-15-preview"), new Tuple("DataMigration", "Tasks", "2018-07-15-preview"), new Tuple("DataMigration", "Usages", "2018-07-15-preview"), diff --git a/src/SDKs/DataMigration/Management.DataMigration/Generated/ServiceTasksOperations.cs b/src/SDKs/DataMigration/Management.DataMigration/Generated/ServiceTasksOperations.cs deleted file mode 100644 index 11778d1067792..0000000000000 --- a/src/SDKs/DataMigration/Management.DataMigration/Generated/ServiceTasksOperations.cs +++ /dev/null @@ -1,640 +0,0 @@ -// -// 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.DataMigration -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using Newtonsoft.Json; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; - using System.Threading; - using System.Threading.Tasks; - - /// - /// ServiceTasksOperations operations. - /// - internal partial class ServiceTasksOperations : IServiceOperations, IServiceTasksOperations - { - /// - /// Initializes a new instance of the ServiceTasksOperations class. - /// - /// - /// Reference to the service client. - /// - /// - /// Thrown when a required parameter is null - /// - internal ServiceTasksOperations(DataMigrationServiceClient client) - { - if (client == null) - { - throw new System.ArgumentNullException("client"); - } - Client = client; - } - - /// - /// Gets a reference to the DataMigrationServiceClient - /// - public DataMigrationServiceClient Client { get; private set; } - - /// - /// Get service level tasks for a service - /// - /// - /// The services resource is the top-level resource that represents the - /// Database Migration Service. This method returns a list of service level - /// tasks owned by a service resource. Some tasks may have a status of Unknown, - /// which indicates that an error occurred while querying the status of that - /// task. - /// - /// - /// Name of the resource group - /// - /// - /// Name of the service - /// - /// - /// Filter tasks by task type - /// - /// - /// 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 Task>> ListWithHttpMessagesAsync(string groupName, string serviceName, string taskType = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - if (groupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "groupName"); - } - if (serviceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "serviceName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("groupName", groupName); - tracingParameters.Add("serviceName", serviceName); - tracingParameters.Add("taskType", taskType); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.DataMigration/services/{serviceName}/serviceTasks").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - _url = _url.Replace("{groupName}", System.Uri.EscapeDataString(groupName)); - _url = _url.Replace("{serviceName}", System.Uri.EscapeDataString(serviceName)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (taskType != null) - { - _queryParameters.Add(string.Format("taskType={0}", System.Uri.EscapeDataString(taskType))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", 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 (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new ApiErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new 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 = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Cancel a service task - /// - /// - /// The service tasks resource is a nested, proxy-only resource representing - /// work performed by a DMS instance. This method cancels a service task if - /// it's currently queued or running. - /// - /// - /// Name of the resource group - /// - /// - /// Name of the service - /// - /// - /// Name of the Task - /// - /// - /// 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 Task> CancelWithHttpMessagesAsync(string groupName, string serviceName, string taskName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } - if (groupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "groupName"); - } - if (serviceName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "serviceName"); - } - if (taskName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "taskName"); - } - if (Client.ApiVersion == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("groupName", groupName); - tracingParameters.Add("serviceName", serviceName); - tracingParameters.Add("taskName", taskName); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Cancel", tracingParameters); - } - // Construct URL - var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.DataMigration/services/{serviceName}/serviceTasks/{taskName}/cancel").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); - _url = _url.Replace("{groupName}", System.Uri.EscapeDataString(groupName)); - _url = _url.Replace("{serviceName}", System.Uri.EscapeDataString(serviceName)); - _url = _url.Replace("{taskName}", System.Uri.EscapeDataString(taskName)); - List _queryParameters = new List(); - if (Client.ApiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", 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 (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new ApiErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new 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 = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - /// - /// Get service level tasks for a service - /// - /// - /// The services resource is the top-level resource that represents the - /// Database Migration Service. This method returns a list of service level - /// tasks owned by a service resource. Some tasks may have a status of Unknown, - /// which indicates that an error occurred while querying the status of that - /// task. - /// - /// - /// 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 Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (nextPageLink == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); - } - // Construct URL - string _url = "{nextLink}"; - _url = _url.Replace("{nextLink}", nextPageLink); - List _queryParameters = new List(); - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new HttpRequestMessage(); - HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (Client.AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", 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 (Client.Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new ApiErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - ApiError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - if (_errorBody != null) - { - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new 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 = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - - } -} diff --git a/src/SDKs/DataMigration/Management.DataMigration/Generated/ServiceTasksOperationsExtensions.cs b/src/SDKs/DataMigration/Management.DataMigration/Generated/ServiceTasksOperationsExtensions.cs deleted file mode 100644 index 1d81622b762ab..0000000000000 --- a/src/SDKs/DataMigration/Management.DataMigration/Generated/ServiceTasksOperationsExtensions.cs +++ /dev/null @@ -1,189 +0,0 @@ -// -// 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.DataMigration -{ - using Microsoft.Rest; - using Microsoft.Rest.Azure; - using Models; - using System.Threading; - using System.Threading.Tasks; - - /// - /// Extension methods for ServiceTasksOperations. - /// - public static partial class ServiceTasksOperationsExtensions - { - /// - /// Get service level tasks for a service - /// - /// - /// The services resource is the top-level resource that represents the - /// Database Migration Service. This method returns a list of service level - /// tasks owned by a service resource. Some tasks may have a status of Unknown, - /// which indicates that an error occurred while querying the status of that - /// task. - /// - /// - /// The operations group for this extension method. - /// - /// - /// Name of the resource group - /// - /// - /// Name of the service - /// - /// - /// Filter tasks by task type - /// - public static IPage List(this IServiceTasksOperations operations, string groupName, string serviceName, string taskType = default(string)) - { - return operations.ListAsync(groupName, serviceName, taskType).GetAwaiter().GetResult(); - } - - /// - /// Get service level tasks for a service - /// - /// - /// The services resource is the top-level resource that represents the - /// Database Migration Service. This method returns a list of service level - /// tasks owned by a service resource. Some tasks may have a status of Unknown, - /// which indicates that an error occurred while querying the status of that - /// task. - /// - /// - /// The operations group for this extension method. - /// - /// - /// Name of the resource group - /// - /// - /// Name of the service - /// - /// - /// Filter tasks by task type - /// - /// - /// The cancellation token. - /// - public static async Task> ListAsync(this IServiceTasksOperations operations, string groupName, string serviceName, string taskType = default(string), CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListWithHttpMessagesAsync(groupName, serviceName, taskType, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Cancel a service task - /// - /// - /// The service tasks resource is a nested, proxy-only resource representing - /// work performed by a DMS instance. This method cancels a service task if - /// it's currently queued or running. - /// - /// - /// The operations group for this extension method. - /// - /// - /// Name of the resource group - /// - /// - /// Name of the service - /// - /// - /// Name of the Task - /// - public static ProjectTask Cancel(this IServiceTasksOperations operations, string groupName, string serviceName, string taskName) - { - return operations.CancelAsync(groupName, serviceName, taskName).GetAwaiter().GetResult(); - } - - /// - /// Cancel a service task - /// - /// - /// The service tasks resource is a nested, proxy-only resource representing - /// work performed by a DMS instance. This method cancels a service task if - /// it's currently queued or running. - /// - /// - /// The operations group for this extension method. - /// - /// - /// Name of the resource group - /// - /// - /// Name of the service - /// - /// - /// Name of the Task - /// - /// - /// The cancellation token. - /// - public static async Task CancelAsync(this IServiceTasksOperations operations, string groupName, string serviceName, string taskName, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.CancelWithHttpMessagesAsync(groupName, serviceName, taskName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - /// - /// Get service level tasks for a service - /// - /// - /// The services resource is the top-level resource that represents the - /// Database Migration Service. This method returns a list of service level - /// tasks owned by a service resource. Some tasks may have a status of Unknown, - /// which indicates that an error occurred while querying the status of that - /// task. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - public static IPage ListNext(this IServiceTasksOperations operations, string nextPageLink) - { - return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); - } - - /// - /// Get service level tasks for a service - /// - /// - /// The services resource is the top-level resource that represents the - /// Database Migration Service. This method returns a list of service level - /// tasks owned by a service resource. Some tasks may have a status of Unknown, - /// which indicates that an error occurred while querying the status of that - /// task. - /// - /// - /// The operations group for this extension method. - /// - /// - /// The NextLink from the previous successful call to List operation. - /// - /// - /// The cancellation token. - /// - public static async Task> ListNextAsync(this IServiceTasksOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) - { - using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } - } - - } -}