< Summary

Class:Microsoft.Azure.Search.SynonymMapsOperations
Assembly:Microsoft.Azure.Search.Service
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Customizations\SynonymMaps\SynonymMapsOperations.Customization.cs
C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Generated\SynonymMapsOperations.cs
Covered lines:378
Uncovered lines:179
Coverable lines:557
Total lines:1286
Line coverage:67.8% (378 of 557)
Covered branches:222
Total branches:354
Branch coverage:62.7% (222 of 354)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
CreateOrUpdateWithHttpMessagesAsync(...)-100%50%
ExistsWithHttpMessagesAsync(...)-100%100%
.ctor(...)-80%50%
get_Client()-100%100%
CreateOrUpdateWithHttpMessagesAsync()-69.29%67.78%
DeleteWithHttpMessagesAsync()-71.03%65.28%
GetWithHttpMessagesAsync()-70%62.9%
ListWithHttpMessagesAsync()-54.17%50%
CreateWithHttpMessagesAsync()-71.43%65.15%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Customizations\SynonymMaps\SynonymMapsOperations.Customization.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for
 3// license information.
 4
 5namespace Microsoft.Azure.Search
 6{
 7    using System.Collections.Generic;
 8    using System.Threading;
 9    using System.Threading.Tasks;
 10    using Microsoft.Rest.Azure;
 11    using Models;
 12
 13    internal partial class SynonymMapsOperations
 14    {
 15        /// <summary>
 16        /// Creates a new synonym map or updates a synonym map if it
 17        /// already exists.
 18        /// <see href="https://docs.microsoft.com/rest/api/searchservice/Update-Synonym-Map" />
 19        /// </summary>
 20        /// <param name='synonymMap'>
 21        /// The definition of the synonym map to create or update.
 22        /// </param>
 23        /// <param name='searchRequestOptions'>
 24        /// Additional parameters for the operation.
 25        /// </param>
 26        /// <param name='accessCondition'>
 27        /// Additional parameters for the operation.
 28        /// </param>
 29        /// <param name='customHeaders'>
 30        /// Headers that will be added to request.
 31        /// </param>
 32        /// <param name='cancellationToken'>
 33        /// The cancellation token.
 34        /// </param>
 35        /// <exception cref="CloudException">
 36        /// Thrown when the operation returned an invalid status code.
 37        /// </exception>
 38        /// <exception cref="Microsoft.Rest.SerializationException">
 39        /// Thrown when unable to deserialize the response.
 40        /// </exception>
 41        /// <exception cref="Microsoft.Rest.ValidationException">
 42        /// Thrown when a required parameter is null.
 43        /// </exception>
 44        /// <exception cref="System.ArgumentNullException">
 45        /// Thrown when a required parameter is null.
 46        /// </exception>
 47        /// <returns>
 48        /// A response object containing the response body and response headers.
 49        /// </returns>
 50        public Task<AzureOperationResponse<SynonymMap>> CreateOrUpdateWithHttpMessagesAsync(SynonymMap synonymMap, Searc
 51        {
 3252            return CreateOrUpdateWithHttpMessagesAsync(synonymMap?.Name, synonymMap, searchRequestOptions, accessConditi
 53        }
 54
 55        /// <summary>
 56        /// Determines whether or not the given synonym map exists in the Azure Cognitive Search service.
 57        /// </summary>
 58        /// <param name="synonymMapName">
 59        /// The name of the synonym map.
 60        /// </param>
 61        /// <param name='searchRequestOptions'>
 62        /// Additional parameters for the operation
 63        /// </param>
 64        /// <param name='customHeaders'>
 65        /// The headers that will be added to request.
 66        /// </param>
 67        /// <param name='cancellationToken'>
 68        /// The cancellation token.
 69        /// </param>
 70        /// <exception cref="CloudException">
 71        /// Thrown when the operation returned an invalid status code.
 72        /// </exception>
 73        /// <exception cref="Microsoft.Rest.SerializationException">
 74        /// Thrown when unable to deserialize the response.
 75        /// </exception>
 76        /// <exception cref="Microsoft.Rest.ValidationException">
 77        /// Thrown when a required parameter is null.
 78        /// </exception>
 79        /// <exception cref="System.ArgumentNullException">
 80        /// Thrown when a required parameter is null.
 81        /// </exception>
 82        /// <returns>
 83        /// A response with the value <c>true</c> if the synonym map exists; <c>false</c> otherwise.
 84        /// </returns>
 85        public Task<AzureOperationResponse<bool>> ExistsWithHttpMessagesAsync(
 86            string synonymMapName,
 87            SearchRequestOptions searchRequestOptions = default(SearchRequestOptions),
 88            Dictionary<string, List<string>> customHeaders = null,
 89            CancellationToken cancellationToken = default(CancellationToken))
 90        {
 491            return ExistsHelper.ExistsFromGetResponse(() =>
 892                this.GetWithHttpMessagesAsync(synonymMapName, searchRequestOptions, customHeaders, cancellationToken));
 93        }
 94    }
 95}

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Search.Service\src\Generated\SynonymMapsOperations.cs

#LineLine coverage
 1// <auto-generated>
 2// Copyright (c) Microsoft Corporation. All rights reserved.
 3// Licensed under the MIT License. See License.txt in the project root for
 4// license information.
 5//
 6// Code generated by Microsoft (R) AutoRest Code Generator.
 7// Changes may cause incorrect behavior and will be lost if the code is
 8// regenerated.
 9// </auto-generated>
 10
 11namespace Microsoft.Azure.Search
 12{
 13    using Microsoft.Rest;
 14    using Microsoft.Rest.Azure;
 15    using Models;
 16    using Newtonsoft.Json;
 17    using System.Collections;
 18    using System.Collections.Generic;
 19    using System.Linq;
 20    using System.Net;
 21    using System.Net.Http;
 22    using System.Threading;
 23    using System.Threading.Tasks;
 24
 25    /// <summary>
 26    /// SynonymMapsOperations operations.
 27    /// </summary>
 28    internal partial class SynonymMapsOperations : IServiceOperations<SearchServiceClient>, ISynonymMapsOperations
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the SynonymMapsOperations class.
 32        /// </summary>
 33        /// <param name='client'>
 34        /// Reference to the service client.
 35        /// </param>
 36        /// <exception cref="System.ArgumentNullException">
 37        /// Thrown when a required parameter is null
 38        /// </exception>
 82439        internal SynonymMapsOperations(SearchServiceClient client)
 40        {
 82441            if (client == null)
 42            {
 043                throw new System.ArgumentNullException("client");
 44            }
 82445            Client = client;
 82446        }
 47
 48        /// <summary>
 49        /// Gets a reference to the SearchServiceClient
 50        /// </summary>
 221051        public SearchServiceClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// Creates a new synonym map or updates a synonym map if it already exists.
 55        /// <see href="https://docs.microsoft.com/rest/api/searchservice/Update-Synonym-Map" />
 56        /// </summary>
 57        /// <param name='synonymMapName'>
 58        /// The name of the synonym map to create or update.
 59        /// </param>
 60        /// <param name='synonymMap'>
 61        /// The definition of the synonym map to create or update.
 62        /// </param>
 63        /// <param name='searchRequestOptions'>
 64        /// Additional parameters for the operation
 65        /// </param>
 66        /// <param name='accessCondition'>
 67        /// Additional parameters for the operation
 68        /// </param>
 69        /// <param name='customHeaders'>
 70        /// Headers that will be added to request.
 71        /// </param>
 72        /// <param name='cancellationToken'>
 73        /// The cancellation token.
 74        /// </param>
 75        /// <exception cref="CloudException">
 76        /// Thrown when the operation returned an invalid status code
 77        /// </exception>
 78        /// <exception cref="SerializationException">
 79        /// Thrown when unable to deserialize the response
 80        /// </exception>
 81        /// <exception cref="ValidationException">
 82        /// Thrown when a required parameter is null
 83        /// </exception>
 84        /// <exception cref="System.ArgumentNullException">
 85        /// Thrown when a required parameter is null
 86        /// </exception>
 87        /// <return>
 88        /// A response object containing the response body and response headers.
 89        /// </return>
 90        public async Task<AzureOperationResponse<SynonymMap>> CreateOrUpdateWithHttpMessagesAsync(string synonymMapName,
 91        {
 3292            if (Client.SearchServiceName == null)
 93            {
 094                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
 95            }
 3296            if (Client.SearchDnsSuffix == null)
 97            {
 098                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
 99            }
 32100            if (synonymMapName == null)
 101            {
 0102                throw new ValidationException(ValidationRules.CannotBeNull, "synonymMapName");
 103            }
 32104            if (synonymMap == null)
 105            {
 0106                throw new ValidationException(ValidationRules.CannotBeNull, "synonymMap");
 107            }
 32108            if (synonymMap != null)
 109            {
 32110                synonymMap.Validate();
 111            }
 32112            if (Client.ApiVersion == null)
 113            {
 0114                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 115            }
 32116            string prefer = "return=representation";
 32117            System.Guid? clientRequestId = default(System.Guid?);
 32118            if (searchRequestOptions != null)
 119            {
 0120                clientRequestId = searchRequestOptions.ClientRequestId;
 121            }
 32122            string ifMatch = default(string);
 32123            if (accessCondition != null)
 124            {
 22125                ifMatch = accessCondition.IfMatch;
 126            }
 32127            string ifNoneMatch = default(string);
 32128            if (accessCondition != null)
 129            {
 22130                ifNoneMatch = accessCondition.IfNoneMatch;
 131            }
 132            // Tracing
 32133            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 32134            string _invocationId = null;
 32135            if (_shouldTrace)
 136            {
 0137                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0138                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0139                tracingParameters.Add("synonymMapName", synonymMapName);
 0140                tracingParameters.Add("synonymMap", synonymMap);
 0141                tracingParameters.Add("prefer", prefer);
 0142                tracingParameters.Add("clientRequestId", clientRequestId);
 0143                tracingParameters.Add("ifMatch", ifMatch);
 0144                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 0145                tracingParameters.Add("cancellationToken", cancellationToken);
 0146                ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters);
 147            }
 148            // Construct URL
 32149            var _baseUrl = Client.BaseUri;
 32150            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "synonymmaps('{synonymMapName}')";
 32151            _url = _url.Replace("{searchServiceName}", Client.SearchServiceName);
 32152            _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
 32153            _url = _url.Replace("{synonymMapName}", System.Uri.EscapeDataString(synonymMapName));
 32154            List<string> _queryParameters = new List<string>();
 32155            if (Client.ApiVersion != null)
 156            {
 32157                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 158            }
 32159            if (_queryParameters.Count > 0)
 160            {
 32161                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 162            }
 163            // Create HTTP transport objects
 32164            var _httpRequest = new HttpRequestMessage();
 32165            HttpResponseMessage _httpResponse = null;
 32166            _httpRequest.Method = new HttpMethod("PUT");
 32167            _httpRequest.RequestUri = new System.Uri(_url);
 168            // Set Headers
 32169            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 170            {
 32171                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 172            }
 32173            if (prefer != null)
 174            {
 32175                if (_httpRequest.Headers.Contains("Prefer"))
 176                {
 0177                    _httpRequest.Headers.Remove("Prefer");
 178                }
 32179                _httpRequest.Headers.TryAddWithoutValidation("Prefer", prefer);
 180            }
 32181            if (Client.AcceptLanguage != null)
 182            {
 32183                if (_httpRequest.Headers.Contains("accept-language"))
 184                {
 0185                    _httpRequest.Headers.Remove("accept-language");
 186                }
 32187                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 188            }
 32189            if (clientRequestId != null)
 190            {
 0191                if (_httpRequest.Headers.Contains("client-request-id"))
 192                {
 0193                    _httpRequest.Headers.Remove("client-request-id");
 194                }
 0195                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser
 196            }
 32197            if (ifMatch != null)
 198            {
 8199                if (_httpRequest.Headers.Contains("If-Match"))
 200                {
 0201                    _httpRequest.Headers.Remove("If-Match");
 202                }
 8203                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 204            }
 32205            if (ifNoneMatch != null)
 206            {
 4207                if (_httpRequest.Headers.Contains("If-None-Match"))
 208                {
 0209                    _httpRequest.Headers.Remove("If-None-Match");
 210                }
 4211                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 212            }
 213
 214
 32215            if (customHeaders != null)
 216            {
 0217                foreach(var _header in customHeaders)
 218                {
 0219                    if (_httpRequest.Headers.Contains(_header.Key))
 220                    {
 0221                        _httpRequest.Headers.Remove(_header.Key);
 222                    }
 0223                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 224                }
 225            }
 226
 227            // Serialize Request
 32228            string _requestContent = null;
 32229            if(synonymMap != null)
 230            {
 32231                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(synonymMap, Client.SerializationSet
 32232                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 32233                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 234            }
 235            // Set Credentials
 32236            if (Client.Credentials != null)
 237            {
 32238                cancellationToken.ThrowIfCancellationRequested();
 32239                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 240            }
 241            // Send Request
 32242            if (_shouldTrace)
 243            {
 0244                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 245            }
 32246            cancellationToken.ThrowIfCancellationRequested();
 32247            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 32248            if (_shouldTrace)
 249            {
 0250                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 251            }
 32252            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 32253            cancellationToken.ThrowIfCancellationRequested();
 32254            string _responseContent = null;
 32255            if ((int)_statusCode != 200 && (int)_statusCode != 201)
 256            {
 6257                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 258                try
 259                {
 6260                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 6261                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 6262                    if (_errorBody != null)
 263                    {
 6264                        ex = new CloudException(_errorBody.Message);
 6265                        ex.Body = _errorBody;
 266                    }
 6267                }
 0268                catch (JsonException)
 269                {
 270                    // Ignore the exception
 0271                }
 6272                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 6273                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 6274                if (_httpResponse.Headers.Contains("request-id"))
 275                {
 6276                    ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 277                }
 6278                if (_shouldTrace)
 279                {
 0280                    ServiceClientTracing.Error(_invocationId, ex);
 281                }
 6282                _httpRequest.Dispose();
 6283                if (_httpResponse != null)
 284                {
 6285                    _httpResponse.Dispose();
 286                }
 6287                throw ex;
 288            }
 289            // Create Result
 26290            var _result = new AzureOperationResponse<SynonymMap>();
 26291            _result.Request = _httpRequest;
 26292            _result.Response = _httpResponse;
 26293            if (_httpResponse.Headers.Contains("request-id"))
 294            {
 26295                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 296            }
 297            // Deserialize Response
 26298            if ((int)_statusCode == 200)
 299            {
 10300                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 301                try
 302                {
 10303                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SynonymMap>(_responseContent, Cl
 10304                }
 0305                catch (JsonException ex)
 306                {
 0307                    _httpRequest.Dispose();
 0308                    if (_httpResponse != null)
 309                    {
 0310                        _httpResponse.Dispose();
 311                    }
 0312                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 313                }
 314            }
 315            // Deserialize Response
 26316            if ((int)_statusCode == 201)
 317            {
 16318                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 319                try
 320                {
 16321                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SynonymMap>(_responseContent, Cl
 16322                }
 0323                catch (JsonException ex)
 324                {
 0325                    _httpRequest.Dispose();
 0326                    if (_httpResponse != null)
 327                    {
 0328                        _httpResponse.Dispose();
 329                    }
 0330                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 331                }
 332            }
 26333            if (_shouldTrace)
 334            {
 0335                ServiceClientTracing.Exit(_invocationId, _result);
 336            }
 26337            return _result;
 26338        }
 339
 340        /// <summary>
 341        /// Deletes a synonym map.
 342        /// <see href="https://docs.microsoft.com/rest/api/searchservice/Delete-Synonym-Map" />
 343        /// </summary>
 344        /// <param name='synonymMapName'>
 345        /// The name of the synonym map to delete.
 346        /// </param>
 347        /// <param name='searchRequestOptions'>
 348        /// Additional parameters for the operation
 349        /// </param>
 350        /// <param name='accessCondition'>
 351        /// Additional parameters for the operation
 352        /// </param>
 353        /// <param name='customHeaders'>
 354        /// Headers that will be added to request.
 355        /// </param>
 356        /// <param name='cancellationToken'>
 357        /// The cancellation token.
 358        /// </param>
 359        /// <exception cref="CloudException">
 360        /// Thrown when the operation returned an invalid status code
 361        /// </exception>
 362        /// <exception cref="ValidationException">
 363        /// Thrown when a required parameter is null
 364        /// </exception>
 365        /// <exception cref="System.ArgumentNullException">
 366        /// Thrown when a required parameter is null
 367        /// </exception>
 368        /// <return>
 369        /// A response object containing the response body and response headers.
 370        /// </return>
 371        public async Task<AzureOperationResponse> DeleteWithHttpMessagesAsync(string synonymMapName, SearchRequestOption
 372        {
 18373            if (Client.SearchServiceName == null)
 374            {
 0375                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
 376            }
 18377            if (Client.SearchDnsSuffix == null)
 378            {
 0379                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
 380            }
 18381            if (synonymMapName == null)
 382            {
 0383                throw new ValidationException(ValidationRules.CannotBeNull, "synonymMapName");
 384            }
 18385            if (Client.ApiVersion == null)
 386            {
 0387                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 388            }
 18389            System.Guid? clientRequestId = default(System.Guid?);
 18390            if (searchRequestOptions != null)
 391            {
 0392                clientRequestId = searchRequestOptions.ClientRequestId;
 393            }
 18394            string ifMatch = default(string);
 18395            if (accessCondition != null)
 396            {
 8397                ifMatch = accessCondition.IfMatch;
 398            }
 18399            string ifNoneMatch = default(string);
 18400            if (accessCondition != null)
 401            {
 8402                ifNoneMatch = accessCondition.IfNoneMatch;
 403            }
 404            // Tracing
 18405            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 18406            string _invocationId = null;
 18407            if (_shouldTrace)
 408            {
 0409                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0410                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0411                tracingParameters.Add("synonymMapName", synonymMapName);
 0412                tracingParameters.Add("clientRequestId", clientRequestId);
 0413                tracingParameters.Add("ifMatch", ifMatch);
 0414                tracingParameters.Add("ifNoneMatch", ifNoneMatch);
 0415                tracingParameters.Add("cancellationToken", cancellationToken);
 0416                ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
 417            }
 418            // Construct URL
 18419            var _baseUrl = Client.BaseUri;
 18420            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "synonymmaps('{synonymMapName}')";
 18421            _url = _url.Replace("{searchServiceName}", Client.SearchServiceName);
 18422            _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
 18423            _url = _url.Replace("{synonymMapName}", System.Uri.EscapeDataString(synonymMapName));
 18424            List<string> _queryParameters = new List<string>();
 18425            if (Client.ApiVersion != null)
 426            {
 18427                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 428            }
 18429            if (_queryParameters.Count > 0)
 430            {
 18431                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 432            }
 433            // Create HTTP transport objects
 18434            var _httpRequest = new HttpRequestMessage();
 18435            HttpResponseMessage _httpResponse = null;
 18436            _httpRequest.Method = new HttpMethod("DELETE");
 18437            _httpRequest.RequestUri = new System.Uri(_url);
 438            // Set Headers
 18439            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 440            {
 18441                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 442            }
 18443            if (Client.AcceptLanguage != null)
 444            {
 18445                if (_httpRequest.Headers.Contains("accept-language"))
 446                {
 0447                    _httpRequest.Headers.Remove("accept-language");
 448                }
 18449                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 450            }
 18451            if (clientRequestId != null)
 452            {
 0453                if (_httpRequest.Headers.Contains("client-request-id"))
 454                {
 0455                    _httpRequest.Headers.Remove("client-request-id");
 456                }
 0457                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser
 458            }
 18459            if (ifMatch != null)
 460            {
 8461                if (_httpRequest.Headers.Contains("If-Match"))
 462                {
 0463                    _httpRequest.Headers.Remove("If-Match");
 464                }
 8465                _httpRequest.Headers.TryAddWithoutValidation("If-Match", ifMatch);
 466            }
 18467            if (ifNoneMatch != null)
 468            {
 0469                if (_httpRequest.Headers.Contains("If-None-Match"))
 470                {
 0471                    _httpRequest.Headers.Remove("If-None-Match");
 472                }
 0473                _httpRequest.Headers.TryAddWithoutValidation("If-None-Match", ifNoneMatch);
 474            }
 475
 476
 18477            if (customHeaders != null)
 478            {
 0479                foreach(var _header in customHeaders)
 480                {
 0481                    if (_httpRequest.Headers.Contains(_header.Key))
 482                    {
 0483                        _httpRequest.Headers.Remove(_header.Key);
 484                    }
 0485                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 486                }
 487            }
 488
 489            // Serialize Request
 18490            string _requestContent = null;
 491            // Set Credentials
 18492            if (Client.Credentials != null)
 493            {
 18494                cancellationToken.ThrowIfCancellationRequested();
 18495                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 496            }
 497            // Send Request
 18498            if (_shouldTrace)
 499            {
 0500                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 501            }
 18502            cancellationToken.ThrowIfCancellationRequested();
 18503            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 18504            if (_shouldTrace)
 505            {
 0506                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 507            }
 18508            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 18509            cancellationToken.ThrowIfCancellationRequested();
 18510            string _responseContent = null;
 18511            if ((int)_statusCode != 204 && (int)_statusCode != 404)
 512            {
 4513                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 514                try
 515                {
 4516                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4517                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 4518                    if (_errorBody != null)
 519                    {
 4520                        ex = new CloudException(_errorBody.Message);
 4521                        ex.Body = _errorBody;
 522                    }
 4523                }
 0524                catch (JsonException)
 525                {
 526                    // Ignore the exception
 0527                }
 4528                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 4529                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 4530                if (_httpResponse.Headers.Contains("request-id"))
 531                {
 4532                    ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 533                }
 4534                if (_shouldTrace)
 535                {
 0536                    ServiceClientTracing.Error(_invocationId, ex);
 537                }
 4538                _httpRequest.Dispose();
 4539                if (_httpResponse != null)
 540                {
 4541                    _httpResponse.Dispose();
 542                }
 4543                throw ex;
 544            }
 545            // Create Result
 14546            var _result = new AzureOperationResponse();
 14547            _result.Request = _httpRequest;
 14548            _result.Response = _httpResponse;
 14549            if (_httpResponse.Headers.Contains("request-id"))
 550            {
 14551                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 552            }
 14553            if (_shouldTrace)
 554            {
 0555                ServiceClientTracing.Exit(_invocationId, _result);
 556            }
 14557            return _result;
 14558        }
 559
 560        /// <summary>
 561        /// Retrieves a synonym map definition.
 562        /// <see href="https://docs.microsoft.com/rest/api/searchservice/Get-Synonym-Map" />
 563        /// </summary>
 564        /// <param name='synonymMapName'>
 565        /// The name of the synonym map to retrieve.
 566        /// </param>
 567        /// <param name='searchRequestOptions'>
 568        /// Additional parameters for the operation
 569        /// </param>
 570        /// <param name='customHeaders'>
 571        /// Headers that will be added to request.
 572        /// </param>
 573        /// <param name='cancellationToken'>
 574        /// The cancellation token.
 575        /// </param>
 576        /// <exception cref="CloudException">
 577        /// Thrown when the operation returned an invalid status code
 578        /// </exception>
 579        /// <exception cref="SerializationException">
 580        /// Thrown when unable to deserialize the response
 581        /// </exception>
 582        /// <exception cref="ValidationException">
 583        /// Thrown when a required parameter is null
 584        /// </exception>
 585        /// <exception cref="System.ArgumentNullException">
 586        /// Thrown when a required parameter is null
 587        /// </exception>
 588        /// <return>
 589        /// A response object containing the response body and response headers.
 590        /// </return>
 591        public async Task<AzureOperationResponse<SynonymMap>> GetWithHttpMessagesAsync(string synonymMapName, SearchRequ
 592        {
 8593            if (Client.SearchServiceName == null)
 594            {
 0595                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
 596            }
 8597            if (Client.SearchDnsSuffix == null)
 598            {
 0599                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
 600            }
 8601            if (synonymMapName == null)
 602            {
 0603                throw new ValidationException(ValidationRules.CannotBeNull, "synonymMapName");
 604            }
 8605            if (Client.ApiVersion == null)
 606            {
 0607                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 608            }
 8609            System.Guid? clientRequestId = default(System.Guid?);
 8610            if (searchRequestOptions != null)
 611            {
 0612                clientRequestId = searchRequestOptions.ClientRequestId;
 613            }
 614            // Tracing
 8615            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 8616            string _invocationId = null;
 8617            if (_shouldTrace)
 618            {
 0619                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0620                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0621                tracingParameters.Add("synonymMapName", synonymMapName);
 0622                tracingParameters.Add("clientRequestId", clientRequestId);
 0623                tracingParameters.Add("cancellationToken", cancellationToken);
 0624                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
 625            }
 626            // Construct URL
 8627            var _baseUrl = Client.BaseUri;
 8628            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "synonymmaps('{synonymMapName}')";
 8629            _url = _url.Replace("{searchServiceName}", Client.SearchServiceName);
 8630            _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
 8631            _url = _url.Replace("{synonymMapName}", System.Uri.EscapeDataString(synonymMapName));
 8632            List<string> _queryParameters = new List<string>();
 8633            if (Client.ApiVersion != null)
 634            {
 8635                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 636            }
 8637            if (_queryParameters.Count > 0)
 638            {
 8639                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 640            }
 641            // Create HTTP transport objects
 8642            var _httpRequest = new HttpRequestMessage();
 8643            HttpResponseMessage _httpResponse = null;
 8644            _httpRequest.Method = new HttpMethod("GET");
 8645            _httpRequest.RequestUri = new System.Uri(_url);
 646            // Set Headers
 8647            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 648            {
 8649                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 650            }
 8651            if (Client.AcceptLanguage != null)
 652            {
 8653                if (_httpRequest.Headers.Contains("accept-language"))
 654                {
 0655                    _httpRequest.Headers.Remove("accept-language");
 656                }
 8657                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 658            }
 8659            if (clientRequestId != null)
 660            {
 0661                if (_httpRequest.Headers.Contains("client-request-id"))
 662                {
 0663                    _httpRequest.Headers.Remove("client-request-id");
 664                }
 0665                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser
 666            }
 667
 668
 8669            if (customHeaders != null)
 670            {
 0671                foreach(var _header in customHeaders)
 672                {
 0673                    if (_httpRequest.Headers.Contains(_header.Key))
 674                    {
 0675                        _httpRequest.Headers.Remove(_header.Key);
 676                    }
 0677                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 678                }
 679            }
 680
 681            // Serialize Request
 8682            string _requestContent = null;
 683            // Set Credentials
 8684            if (Client.Credentials != null)
 685            {
 8686                cancellationToken.ThrowIfCancellationRequested();
 8687                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 688            }
 689            // Send Request
 8690            if (_shouldTrace)
 691            {
 0692                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 693            }
 8694            cancellationToken.ThrowIfCancellationRequested();
 8695            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 8696            if (_shouldTrace)
 697            {
 0698                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 699            }
 8700            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 8701            cancellationToken.ThrowIfCancellationRequested();
 8702            string _responseContent = null;
 8703            if ((int)_statusCode != 200)
 704            {
 4705                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 706                try
 707                {
 4708                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 4709                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 4710                    if (_errorBody != null)
 711                    {
 4712                        ex = new CloudException(_errorBody.Message);
 4713                        ex.Body = _errorBody;
 714                    }
 4715                }
 0716                catch (JsonException)
 717                {
 718                    // Ignore the exception
 0719                }
 4720                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 4721                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 4722                if (_httpResponse.Headers.Contains("request-id"))
 723                {
 4724                    ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 725                }
 4726                if (_shouldTrace)
 727                {
 0728                    ServiceClientTracing.Error(_invocationId, ex);
 729                }
 4730                _httpRequest.Dispose();
 4731                if (_httpResponse != null)
 732                {
 4733                    _httpResponse.Dispose();
 734                }
 4735                throw ex;
 736            }
 737            // Create Result
 4738            var _result = new AzureOperationResponse<SynonymMap>();
 4739            _result.Request = _httpRequest;
 4740            _result.Response = _httpResponse;
 4741            if (_httpResponse.Headers.Contains("request-id"))
 742            {
 4743                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 744            }
 745            // Deserialize Response
 4746            if ((int)_statusCode == 200)
 747            {
 4748                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 749                try
 750                {
 4751                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SynonymMap>(_responseContent, Cl
 4752                }
 0753                catch (JsonException ex)
 754                {
 0755                    _httpRequest.Dispose();
 0756                    if (_httpResponse != null)
 757                    {
 0758                        _httpResponse.Dispose();
 759                    }
 0760                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 761                }
 762            }
 4763            if (_shouldTrace)
 764            {
 0765                ServiceClientTracing.Exit(_invocationId, _result);
 766            }
 4767            return _result;
 4768        }
 769
 770        /// <summary>
 771        /// Lists all synonym maps available for a search service.
 772        /// <see href="https://docs.microsoft.com/rest/api/searchservice/List-Synonym-Maps" />
 773        /// </summary>
 774        /// <param name='searchRequestOptions'>
 775        /// Additional parameters for the operation
 776        /// </param>
 777        /// <param name='customHeaders'>
 778        /// Headers that will be added to request.
 779        /// </param>
 780        /// <param name='cancellationToken'>
 781        /// The cancellation token.
 782        /// </param>
 783        /// <exception cref="CloudException">
 784        /// Thrown when the operation returned an invalid status code
 785        /// </exception>
 786        /// <exception cref="SerializationException">
 787        /// Thrown when unable to deserialize the response
 788        /// </exception>
 789        /// <exception cref="ValidationException">
 790        /// Thrown when a required parameter is null
 791        /// </exception>
 792        /// <exception cref="System.ArgumentNullException">
 793        /// Thrown when a required parameter is null
 794        /// </exception>
 795        /// <return>
 796        /// A response object containing the response body and response headers.
 797        /// </return>
 798        public async Task<AzureOperationResponse<SynonymMapListResult>> ListWithHttpMessagesAsync(SearchRequestOptions s
 799        {
 2800            if (Client.SearchServiceName == null)
 801            {
 0802                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
 803            }
 2804            if (Client.SearchDnsSuffix == null)
 805            {
 0806                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
 807            }
 2808            if (Client.ApiVersion == null)
 809            {
 0810                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 811            }
 2812            System.Guid? clientRequestId = default(System.Guid?);
 2813            if (searchRequestOptions != null)
 814            {
 0815                clientRequestId = searchRequestOptions.ClientRequestId;
 816            }
 817            // Tracing
 2818            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 2819            string _invocationId = null;
 2820            if (_shouldTrace)
 821            {
 0822                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0823                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0824                tracingParameters.Add("clientRequestId", clientRequestId);
 0825                tracingParameters.Add("cancellationToken", cancellationToken);
 0826                ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
 827            }
 828            // Construct URL
 2829            var _baseUrl = Client.BaseUri;
 2830            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "synonymmaps";
 2831            _url = _url.Replace("{searchServiceName}", Client.SearchServiceName);
 2832            _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
 2833            List<string> _queryParameters = new List<string>();
 2834            if (Client.ApiVersion != null)
 835            {
 2836                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 837            }
 2838            if (_queryParameters.Count > 0)
 839            {
 2840                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 841            }
 842            // Create HTTP transport objects
 2843            var _httpRequest = new HttpRequestMessage();
 2844            HttpResponseMessage _httpResponse = null;
 2845            _httpRequest.Method = new HttpMethod("GET");
 2846            _httpRequest.RequestUri = new System.Uri(_url);
 847            // Set Headers
 2848            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 849            {
 2850                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 851            }
 2852            if (Client.AcceptLanguage != null)
 853            {
 2854                if (_httpRequest.Headers.Contains("accept-language"))
 855                {
 0856                    _httpRequest.Headers.Remove("accept-language");
 857                }
 2858                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 859            }
 2860            if (clientRequestId != null)
 861            {
 0862                if (_httpRequest.Headers.Contains("client-request-id"))
 863                {
 0864                    _httpRequest.Headers.Remove("client-request-id");
 865                }
 0866                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser
 867            }
 868
 869
 2870            if (customHeaders != null)
 871            {
 0872                foreach(var _header in customHeaders)
 873                {
 0874                    if (_httpRequest.Headers.Contains(_header.Key))
 875                    {
 0876                        _httpRequest.Headers.Remove(_header.Key);
 877                    }
 0878                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 879                }
 880            }
 881
 882            // Serialize Request
 2883            string _requestContent = null;
 884            // Set Credentials
 2885            if (Client.Credentials != null)
 886            {
 2887                cancellationToken.ThrowIfCancellationRequested();
 2888                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 889            }
 890            // Send Request
 2891            if (_shouldTrace)
 892            {
 0893                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 894            }
 2895            cancellationToken.ThrowIfCancellationRequested();
 2896            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 2897            if (_shouldTrace)
 898            {
 0899                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 900            }
 2901            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 2902            cancellationToken.ThrowIfCancellationRequested();
 2903            string _responseContent = null;
 2904            if ((int)_statusCode != 200)
 905            {
 0906                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 907                try
 908                {
 0909                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0910                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0911                    if (_errorBody != null)
 912                    {
 0913                        ex = new CloudException(_errorBody.Message);
 0914                        ex.Body = _errorBody;
 915                    }
 0916                }
 0917                catch (JsonException)
 918                {
 919                    // Ignore the exception
 0920                }
 0921                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0922                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0923                if (_httpResponse.Headers.Contains("request-id"))
 924                {
 0925                    ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 926                }
 0927                if (_shouldTrace)
 928                {
 0929                    ServiceClientTracing.Error(_invocationId, ex);
 930                }
 0931                _httpRequest.Dispose();
 0932                if (_httpResponse != null)
 933                {
 0934                    _httpResponse.Dispose();
 935                }
 0936                throw ex;
 937            }
 938            // Create Result
 2939            var _result = new AzureOperationResponse<SynonymMapListResult>();
 2940            _result.Request = _httpRequest;
 2941            _result.Response = _httpResponse;
 2942            if (_httpResponse.Headers.Contains("request-id"))
 943            {
 2944                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 945            }
 946            // Deserialize Response
 2947            if ((int)_statusCode == 200)
 948            {
 2949                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 950                try
 951                {
 2952                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SynonymMapListResult>(_responseC
 2953                }
 0954                catch (JsonException ex)
 955                {
 0956                    _httpRequest.Dispose();
 0957                    if (_httpResponse != null)
 958                    {
 0959                        _httpResponse.Dispose();
 960                    }
 0961                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 962                }
 963            }
 2964            if (_shouldTrace)
 965            {
 0966                ServiceClientTracing.Exit(_invocationId, _result);
 967            }
 2968            return _result;
 2969        }
 970
 971        /// <summary>
 972        /// Creates a new synonym map.
 973        /// <see href="https://docs.microsoft.com/rest/api/searchservice/Create-Synonym-Map" />
 974        /// </summary>
 975        /// <param name='synonymMap'>
 976        /// The definition of the synonym map to create.
 977        /// </param>
 978        /// <param name='searchRequestOptions'>
 979        /// Additional parameters for the operation
 980        /// </param>
 981        /// <param name='customHeaders'>
 982        /// Headers that will be added to request.
 983        /// </param>
 984        /// <param name='cancellationToken'>
 985        /// The cancellation token.
 986        /// </param>
 987        /// <exception cref="CloudException">
 988        /// Thrown when the operation returned an invalid status code
 989        /// </exception>
 990        /// <exception cref="SerializationException">
 991        /// Thrown when unable to deserialize the response
 992        /// </exception>
 993        /// <exception cref="ValidationException">
 994        /// Thrown when a required parameter is null
 995        /// </exception>
 996        /// <exception cref="System.ArgumentNullException">
 997        /// Thrown when a required parameter is null
 998        /// </exception>
 999        /// <return>
 1000        /// A response object containing the response body and response headers.
 1001        /// </return>
 1002        public async Task<AzureOperationResponse<SynonymMap>> CreateWithHttpMessagesAsync(SynonymMap synonymMap, SearchR
 1003        {
 241004            if (Client.SearchServiceName == null)
 1005            {
 01006                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
 1007            }
 241008            if (Client.SearchDnsSuffix == null)
 1009            {
 01010                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
 1011            }
 241012            if (synonymMap == null)
 1013            {
 01014                throw new ValidationException(ValidationRules.CannotBeNull, "synonymMap");
 1015            }
 241016            if (synonymMap != null)
 1017            {
 241018                synonymMap.Validate();
 1019            }
 241020            if (Client.ApiVersion == null)
 1021            {
 01022                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 1023            }
 241024            System.Guid? clientRequestId = default(System.Guid?);
 241025            if (searchRequestOptions != null)
 1026            {
 01027                clientRequestId = searchRequestOptions.ClientRequestId;
 1028            }
 1029            // Tracing
 241030            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 241031            string _invocationId = null;
 241032            if (_shouldTrace)
 1033            {
 01034                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 01035                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 01036                tracingParameters.Add("synonymMap", synonymMap);
 01037                tracingParameters.Add("clientRequestId", clientRequestId);
 01038                tracingParameters.Add("cancellationToken", cancellationToken);
 01039                ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
 1040            }
 1041            // Construct URL
 241042            var _baseUrl = Client.BaseUri;
 241043            var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "synonymmaps";
 241044            _url = _url.Replace("{searchServiceName}", Client.SearchServiceName);
 241045            _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
 241046            List<string> _queryParameters = new List<string>();
 241047            if (Client.ApiVersion != null)
 1048            {
 241049                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 1050            }
 241051            if (_queryParameters.Count > 0)
 1052            {
 241053                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 1054            }
 1055            // Create HTTP transport objects
 241056            var _httpRequest = new HttpRequestMessage();
 241057            HttpResponseMessage _httpResponse = null;
 241058            _httpRequest.Method = new HttpMethod("POST");
 241059            _httpRequest.RequestUri = new System.Uri(_url);
 1060            // Set Headers
 241061            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 1062            {
 241063                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString());
 1064            }
 241065            if (Client.AcceptLanguage != null)
 1066            {
 241067                if (_httpRequest.Headers.Contains("accept-language"))
 1068                {
 01069                    _httpRequest.Headers.Remove("accept-language");
 1070                }
 241071                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 1072            }
 241073            if (clientRequestId != null)
 1074            {
 01075                if (_httpRequest.Headers.Contains("client-request-id"))
 1076                {
 01077                    _httpRequest.Headers.Remove("client-request-id");
 1078                }
 01079                _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser
 1080            }
 1081
 1082
 241083            if (customHeaders != null)
 1084            {
 01085                foreach(var _header in customHeaders)
 1086                {
 01087                    if (_httpRequest.Headers.Contains(_header.Key))
 1088                    {
 01089                        _httpRequest.Headers.Remove(_header.Key);
 1090                    }
 01091                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 1092                }
 1093            }
 1094
 1095            // Serialize Request
 241096            string _requestContent = null;
 241097            if(synonymMap != null)
 1098            {
 241099                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(synonymMap, Client.SerializationSet
 241100                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 241101                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 1102            }
 1103            // Set Credentials
 241104            if (Client.Credentials != null)
 1105            {
 241106                cancellationToken.ThrowIfCancellationRequested();
 241107                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 1108            }
 1109            // Send Request
 241110            if (_shouldTrace)
 1111            {
 01112                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 1113            }
 241114            cancellationToken.ThrowIfCancellationRequested();
 241115            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 241116            if (_shouldTrace)
 1117            {
 01118                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 1119            }
 241120            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 241121            cancellationToken.ThrowIfCancellationRequested();
 241122            string _responseContent = null;
 241123            if ((int)_statusCode != 201)
 1124            {
 21125                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 1126                try
 1127                {
 21128                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 21129                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 21130                    if (_errorBody != null)
 1131                    {
 21132                        ex = new CloudException(_errorBody.Message);
 21133                        ex.Body = _errorBody;
 1134                    }
 21135                }
 01136                catch (JsonException)
 1137                {
 1138                    // Ignore the exception
 01139                }
 21140                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 21141                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 21142                if (_httpResponse.Headers.Contains("request-id"))
 1143                {
 21144                    ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1145                }
 21146                if (_shouldTrace)
 1147                {
 01148                    ServiceClientTracing.Error(_invocationId, ex);
 1149                }
 21150                _httpRequest.Dispose();
 21151                if (_httpResponse != null)
 1152                {
 21153                    _httpResponse.Dispose();
 1154                }
 21155                throw ex;
 1156            }
 1157            // Create Result
 221158            var _result = new AzureOperationResponse<SynonymMap>();
 221159            _result.Request = _httpRequest;
 221160            _result.Response = _httpResponse;
 221161            if (_httpResponse.Headers.Contains("request-id"))
 1162            {
 221163                _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault();
 1164            }
 1165            // Deserialize Response
 221166            if ((int)_statusCode == 201)
 1167            {
 221168                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 1169                try
 1170                {
 221171                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SynonymMap>(_responseContent, Cl
 221172                }
 01173                catch (JsonException ex)
 1174                {
 01175                    _httpRequest.Dispose();
 01176                    if (_httpResponse != null)
 1177                    {
 01178                        _httpResponse.Dispose();
 1179                    }
 01180                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 1181                }
 1182            }
 221183            if (_shouldTrace)
 1184            {
 01185                ServiceClientTracing.Exit(_invocationId, _result);
 1186            }
 221187            return _result;
 221188        }
 1189
 1190    }
 1191}