|  |  | 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 |  |  | 
|  |  | 11 |  | namespace 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 |  |     /// DocumentsProxyOperations operations. | 
|  |  | 27 |  |     /// </summary> | 
|  |  | 28 |  |     internal partial class DocumentsProxyOperations : IServiceOperations<SearchIndexClient>, IDocumentsProxyOperations | 
|  |  | 29 |  |     { | 
|  |  | 30 |  |         /// <summary> | 
|  |  | 31 |  |         /// Initializes a new instance of the DocumentsProxyOperations 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> | 
|  | 688 | 39 |  |         internal DocumentsProxyOperations(SearchIndexClient client) | 
|  |  | 40 |  |         { | 
|  | 688 | 41 |  |             if (client == null) | 
|  |  | 42 |  |             { | 
|  | 0 | 43 |  |                 throw new System.ArgumentNullException("client"); | 
|  |  | 44 |  |             } | 
|  | 688 | 45 |  |             Client = client; | 
|  | 688 | 46 |  |         } | 
|  |  | 47 |  |  | 
|  |  | 48 |  |         /// <summary> | 
|  |  | 49 |  |         /// Gets a reference to the SearchIndexClient | 
|  |  | 50 |  |         /// </summary> | 
|  | 16444 | 51 |  |         public SearchIndexClient Client { get; private set; } | 
|  |  | 52 |  |  | 
|  |  | 53 |  |         /// <summary> | 
|  |  | 54 |  |         /// Queries the number of documents in the index. | 
|  |  | 55 |  |         /// <see href="https://docs.microsoft.com/rest/api/searchservice/Count-Documents" /> | 
|  |  | 56 |  |         /// </summary> | 
|  |  | 57 |  |         /// <param name='searchRequestOptions'> | 
|  |  | 58 |  |         /// Additional parameters for the operation | 
|  |  | 59 |  |         /// </param> | 
|  |  | 60 |  |         /// <param name='customHeaders'> | 
|  |  | 61 |  |         /// Headers that will be added to request. | 
|  |  | 62 |  |         /// </param> | 
|  |  | 63 |  |         /// <param name='cancellationToken'> | 
|  |  | 64 |  |         /// The cancellation token. | 
|  |  | 65 |  |         /// </param> | 
|  |  | 66 |  |         /// <exception cref="CloudException"> | 
|  |  | 67 |  |         /// Thrown when the operation returned an invalid status code | 
|  |  | 68 |  |         /// </exception> | 
|  |  | 69 |  |         /// <exception cref="SerializationException"> | 
|  |  | 70 |  |         /// Thrown when unable to deserialize the response | 
|  |  | 71 |  |         /// </exception> | 
|  |  | 72 |  |         /// <exception cref="ValidationException"> | 
|  |  | 73 |  |         /// Thrown when a required parameter is null | 
|  |  | 74 |  |         /// </exception> | 
|  |  | 75 |  |         /// <exception cref="System.ArgumentNullException"> | 
|  |  | 76 |  |         /// Thrown when a required parameter is null | 
|  |  | 77 |  |         /// </exception> | 
|  |  | 78 |  |         /// <return> | 
|  |  | 79 |  |         /// A response object containing the response body and response headers. | 
|  |  | 80 |  |         /// </return> | 
|  |  | 81 |  |         public async Task<AzureOperationResponse<long?>> CountWithHttpMessagesAsync(SearchRequestOptions searchRequestOp | 
|  |  | 82 |  |         { | 
|  | 38 | 83 |  |             if (Client.SearchServiceName == null) | 
|  |  | 84 |  |             { | 
|  | 0 | 85 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName"); | 
|  |  | 86 |  |             } | 
|  | 38 | 87 |  |             if (Client.SearchDnsSuffix == null) | 
|  |  | 88 |  |             { | 
|  | 0 | 89 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix"); | 
|  |  | 90 |  |             } | 
|  | 38 | 91 |  |             if (Client.IndexName == null) | 
|  |  | 92 |  |             { | 
|  | 0 | 93 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.IndexName"); | 
|  |  | 94 |  |             } | 
|  | 38 | 95 |  |             if (Client.ApiVersion == null) | 
|  |  | 96 |  |             { | 
|  | 0 | 97 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); | 
|  |  | 98 |  |             } | 
|  | 38 | 99 |  |             System.Guid? clientRequestId = default(System.Guid?); | 
|  | 38 | 100 |  |             if (searchRequestOptions != null) | 
|  |  | 101 |  |             { | 
|  | 2 | 102 |  |                 clientRequestId = searchRequestOptions.ClientRequestId; | 
|  |  | 103 |  |             } | 
|  |  | 104 |  |             // Tracing | 
|  | 38 | 105 |  |             bool _shouldTrace = ServiceClientTracing.IsEnabled; | 
|  | 38 | 106 |  |             string _invocationId = null; | 
|  | 38 | 107 |  |             if (_shouldTrace) | 
|  |  | 108 |  |             { | 
|  | 0 | 109 |  |                 _invocationId = ServiceClientTracing.NextInvocationId.ToString(); | 
|  | 0 | 110 |  |                 Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); | 
|  | 0 | 111 |  |                 tracingParameters.Add("clientRequestId", clientRequestId); | 
|  | 0 | 112 |  |                 tracingParameters.Add("cancellationToken", cancellationToken); | 
|  | 0 | 113 |  |                 ServiceClientTracing.Enter(_invocationId, this, "Count", tracingParameters); | 
|  |  | 114 |  |             } | 
|  |  | 115 |  |             // Construct URL | 
|  | 38 | 116 |  |             var _baseUrl = Client.BaseUri; | 
|  | 38 | 117 |  |             var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "docs/$count"; | 
|  | 38 | 118 |  |             _url = _url.Replace("{searchServiceName}", Client.SearchServiceName); | 
|  | 38 | 119 |  |             _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix); | 
|  | 38 | 120 |  |             _url = _url.Replace("{indexName}", Client.IndexName); | 
|  | 38 | 121 |  |             List<string> _queryParameters = new List<string>(); | 
|  | 38 | 122 |  |             if (Client.ApiVersion != null) | 
|  |  | 123 |  |             { | 
|  | 38 | 124 |  |                 _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); | 
|  |  | 125 |  |             } | 
|  | 38 | 126 |  |             if (_queryParameters.Count > 0) | 
|  |  | 127 |  |             { | 
|  | 38 | 128 |  |                 _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); | 
|  |  | 129 |  |             } | 
|  |  | 130 |  |             // Create HTTP transport objects | 
|  | 38 | 131 |  |             var _httpRequest = new HttpRequestMessage(); | 
|  | 38 | 132 |  |             HttpResponseMessage _httpResponse = null; | 
|  | 38 | 133 |  |             _httpRequest.Method = new HttpMethod("GET"); | 
|  | 38 | 134 |  |             _httpRequest.RequestUri = new System.Uri(_url); | 
|  |  | 135 |  |             // Set Headers | 
|  | 38 | 136 |  |             if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) | 
|  |  | 137 |  |             { | 
|  | 38 | 138 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); | 
|  |  | 139 |  |             } | 
|  | 38 | 140 |  |             if (Client.AcceptLanguage != null) | 
|  |  | 141 |  |             { | 
|  | 38 | 142 |  |                 if (_httpRequest.Headers.Contains("accept-language")) | 
|  |  | 143 |  |                 { | 
|  | 0 | 144 |  |                     _httpRequest.Headers.Remove("accept-language"); | 
|  |  | 145 |  |                 } | 
|  | 38 | 146 |  |                 _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); | 
|  |  | 147 |  |             } | 
|  | 38 | 148 |  |             if (clientRequestId != null) | 
|  |  | 149 |  |             { | 
|  | 2 | 150 |  |                 if (_httpRequest.Headers.Contains("client-request-id")) | 
|  |  | 151 |  |                 { | 
|  | 2 | 152 |  |                     _httpRequest.Headers.Remove("client-request-id"); | 
|  |  | 153 |  |                 } | 
|  | 2 | 154 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser | 
|  |  | 155 |  |             } | 
|  |  | 156 |  |  | 
|  |  | 157 |  |  | 
|  | 38 | 158 |  |             if (customHeaders != null) | 
|  |  | 159 |  |             { | 
|  | 0 | 160 |  |                 foreach(var _header in customHeaders) | 
|  |  | 161 |  |                 { | 
|  | 0 | 162 |  |                     if (_httpRequest.Headers.Contains(_header.Key)) | 
|  |  | 163 |  |                     { | 
|  | 0 | 164 |  |                         _httpRequest.Headers.Remove(_header.Key); | 
|  |  | 165 |  |                     } | 
|  | 0 | 166 |  |                     _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); | 
|  |  | 167 |  |                 } | 
|  |  | 168 |  |             } | 
|  |  | 169 |  |  | 
|  |  | 170 |  |             // Serialize Request | 
|  | 38 | 171 |  |             string _requestContent = null; | 
|  |  | 172 |  |             // Set Credentials | 
|  | 38 | 173 |  |             if (Client.Credentials != null) | 
|  |  | 174 |  |             { | 
|  | 38 | 175 |  |                 cancellationToken.ThrowIfCancellationRequested(); | 
|  | 38 | 176 |  |                 await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  |  | 177 |  |             } | 
|  |  | 178 |  |             // Send Request | 
|  | 38 | 179 |  |             if (_shouldTrace) | 
|  |  | 180 |  |             { | 
|  | 0 | 181 |  |                 ServiceClientTracing.SendRequest(_invocationId, _httpRequest); | 
|  |  | 182 |  |             } | 
|  | 38 | 183 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 38 | 184 |  |             _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  | 38 | 185 |  |             if (_shouldTrace) | 
|  |  | 186 |  |             { | 
|  | 0 | 187 |  |                 ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); | 
|  |  | 188 |  |             } | 
|  | 38 | 189 |  |             HttpStatusCode _statusCode = _httpResponse.StatusCode; | 
|  | 38 | 190 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 38 | 191 |  |             string _responseContent = null; | 
|  | 38 | 192 |  |             if ((int)_statusCode != 200) | 
|  |  | 193 |  |             { | 
|  | 0 | 194 |  |                 var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode | 
|  |  | 195 |  |                 try | 
|  |  | 196 |  |                 { | 
|  | 0 | 197 |  |                     _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  | 0 | 198 |  |                     CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC | 
|  | 0 | 199 |  |                     if (_errorBody != null) | 
|  |  | 200 |  |                     { | 
|  | 0 | 201 |  |                         ex = new CloudException(_errorBody.Message); | 
|  | 0 | 202 |  |                         ex.Body = _errorBody; | 
|  |  | 203 |  |                     } | 
|  | 0 | 204 |  |                 } | 
|  | 0 | 205 |  |                 catch (JsonException) | 
|  |  | 206 |  |                 { | 
|  |  | 207 |  |                     // Ignore the exception | 
|  | 0 | 208 |  |                 } | 
|  | 0 | 209 |  |                 ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); | 
|  | 0 | 210 |  |                 ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); | 
|  | 0 | 211 |  |                 if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 212 |  |                 { | 
|  | 0 | 213 |  |                     ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 214 |  |                 } | 
|  | 0 | 215 |  |                 if (_shouldTrace) | 
|  |  | 216 |  |                 { | 
|  | 0 | 217 |  |                     ServiceClientTracing.Error(_invocationId, ex); | 
|  |  | 218 |  |                 } | 
|  | 0 | 219 |  |                 _httpRequest.Dispose(); | 
|  | 0 | 220 |  |                 if (_httpResponse != null) | 
|  |  | 221 |  |                 { | 
|  | 0 | 222 |  |                     _httpResponse.Dispose(); | 
|  |  | 223 |  |                 } | 
|  | 0 | 224 |  |                 throw ex; | 
|  |  | 225 |  |             } | 
|  |  | 226 |  |             // Create Result | 
|  | 38 | 227 |  |             var _result = new AzureOperationResponse<long?>(); | 
|  | 38 | 228 |  |             _result.Request = _httpRequest; | 
|  | 38 | 229 |  |             _result.Response = _httpResponse; | 
|  | 38 | 230 |  |             if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 231 |  |             { | 
|  | 38 | 232 |  |                 _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 233 |  |             } | 
|  |  | 234 |  |             // Deserialize Response | 
|  | 38 | 235 |  |             if ((int)_statusCode == 200) | 
|  |  | 236 |  |             { | 
|  | 38 | 237 |  |                 _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  |  | 238 |  |                 try | 
|  |  | 239 |  |                 { | 
|  | 38 | 240 |  |                     _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<long?>(_responseContent, respons | 
|  | 38 | 241 |  |                 } | 
|  | 0 | 242 |  |                 catch (JsonException ex) | 
|  |  | 243 |  |                 { | 
|  | 0 | 244 |  |                     _httpRequest.Dispose(); | 
|  | 0 | 245 |  |                     if (_httpResponse != null) | 
|  |  | 246 |  |                     { | 
|  | 0 | 247 |  |                         _httpResponse.Dispose(); | 
|  |  | 248 |  |                     } | 
|  | 0 | 249 |  |                     throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); | 
|  |  | 250 |  |                 } | 
|  |  | 251 |  |             } | 
|  | 38 | 252 |  |             if (_shouldTrace) | 
|  |  | 253 |  |             { | 
|  | 0 | 254 |  |                 ServiceClientTracing.Exit(_invocationId, _result); | 
|  |  | 255 |  |             } | 
|  | 38 | 256 |  |             return _result; | 
|  | 38 | 257 |  |         } | 
|  |  | 258 |  |  | 
|  |  | 259 |  |         /// <summary> | 
|  |  | 260 |  |         /// Searches for documents in the index. | 
|  |  | 261 |  |         /// <see href="https://docs.microsoft.com/rest/api/searchservice/Search-Documents" /> | 
|  |  | 262 |  |         /// </summary> | 
|  |  | 263 |  |         /// <param name='searchText'> | 
|  |  | 264 |  |         /// A full-text search query expression; Use "*" or omit this parameter to | 
|  |  | 265 |  |         /// match all documents. | 
|  |  | 266 |  |         /// </param> | 
|  |  | 267 |  |         /// <param name='searchParameters'> | 
|  |  | 268 |  |         /// Additional parameters for the operation | 
|  |  | 269 |  |         /// </param> | 
|  |  | 270 |  |         /// <param name='searchRequestOptions'> | 
|  |  | 271 |  |         /// Additional parameters for the operation | 
|  |  | 272 |  |         /// </param> | 
|  |  | 273 |  |         /// <param name='customHeaders'> | 
|  |  | 274 |  |         /// Headers that will be added to request. | 
|  |  | 275 |  |         /// </param> | 
|  |  | 276 |  |         /// <param name='cancellationToken'> | 
|  |  | 277 |  |         /// The cancellation token. | 
|  |  | 278 |  |         /// </param> | 
|  |  | 279 |  |         /// <exception cref="CloudException"> | 
|  |  | 280 |  |         /// Thrown when the operation returned an invalid status code | 
|  |  | 281 |  |         /// </exception> | 
|  |  | 282 |  |         /// <exception cref="SerializationException"> | 
|  |  | 283 |  |         /// Thrown when unable to deserialize the response | 
|  |  | 284 |  |         /// </exception> | 
|  |  | 285 |  |         /// <exception cref="ValidationException"> | 
|  |  | 286 |  |         /// Thrown when a required parameter is null | 
|  |  | 287 |  |         /// </exception> | 
|  |  | 288 |  |         /// <exception cref="System.ArgumentNullException"> | 
|  |  | 289 |  |         /// Thrown when a required parameter is null | 
|  |  | 290 |  |         /// </exception> | 
|  |  | 291 |  |         /// <return> | 
|  |  | 292 |  |         /// A response object containing the response body and response headers. | 
|  |  | 293 |  |         /// </return> | 
|  |  | 294 |  |         public async Task<AzureOperationResponse<DocumentSearchResult<T>>> SearchGetWithHttpMessagesAsync<T>(string sear | 
|  |  | 295 |  |         { | 
|  | 56 | 296 |  |             if (Client.SearchServiceName == null) | 
|  |  | 297 |  |             { | 
|  | 0 | 298 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName"); | 
|  |  | 299 |  |             } | 
|  | 56 | 300 |  |             if (Client.SearchDnsSuffix == null) | 
|  |  | 301 |  |             { | 
|  | 0 | 302 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix"); | 
|  |  | 303 |  |             } | 
|  | 56 | 304 |  |             if (Client.IndexName == null) | 
|  |  | 305 |  |             { | 
|  | 0 | 306 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.IndexName"); | 
|  |  | 307 |  |             } | 
|  | 56 | 308 |  |             if (Client.ApiVersion == null) | 
|  |  | 309 |  |             { | 
|  | 0 | 310 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); | 
|  |  | 311 |  |             } | 
|  | 56 | 312 |  |             bool includeTotalResultCount = default(bool); | 
|  | 56 | 313 |  |             if (searchParameters != null) | 
|  |  | 314 |  |             { | 
|  | 56 | 315 |  |                 includeTotalResultCount = searchParameters.IncludeTotalResultCount; | 
|  |  | 316 |  |             } | 
|  | 56 | 317 |  |             IList<string> facets = default(IList<string>); | 
|  | 56 | 318 |  |             if (searchParameters != null) | 
|  |  | 319 |  |             { | 
|  | 56 | 320 |  |                 facets = searchParameters.Facets; | 
|  |  | 321 |  |             } | 
|  | 56 | 322 |  |             string filter = default(string); | 
|  | 56 | 323 |  |             if (searchParameters != null) | 
|  |  | 324 |  |             { | 
|  | 56 | 325 |  |                 filter = searchParameters.Filter; | 
|  |  | 326 |  |             } | 
|  | 56 | 327 |  |             IList<string> highlightFields = default(IList<string>); | 
|  | 56 | 328 |  |             if (searchParameters != null) | 
|  |  | 329 |  |             { | 
|  | 56 | 330 |  |                 highlightFields = searchParameters.HighlightFields; | 
|  |  | 331 |  |             } | 
|  | 56 | 332 |  |             string highlightPostTag = default(string); | 
|  | 56 | 333 |  |             if (searchParameters != null) | 
|  |  | 334 |  |             { | 
|  | 56 | 335 |  |                 highlightPostTag = searchParameters.HighlightPostTag; | 
|  |  | 336 |  |             } | 
|  | 56 | 337 |  |             string highlightPreTag = default(string); | 
|  | 56 | 338 |  |             if (searchParameters != null) | 
|  |  | 339 |  |             { | 
|  | 56 | 340 |  |                 highlightPreTag = searchParameters.HighlightPreTag; | 
|  |  | 341 |  |             } | 
|  | 56 | 342 |  |             double? minimumCoverage = default(double?); | 
|  | 56 | 343 |  |             if (searchParameters != null) | 
|  |  | 344 |  |             { | 
|  | 56 | 345 |  |                 minimumCoverage = searchParameters.MinimumCoverage; | 
|  |  | 346 |  |             } | 
|  | 56 | 347 |  |             IList<string> orderBy = default(IList<string>); | 
|  | 56 | 348 |  |             if (searchParameters != null) | 
|  |  | 349 |  |             { | 
|  | 56 | 350 |  |                 orderBy = searchParameters.OrderBy; | 
|  |  | 351 |  |             } | 
|  | 56 | 352 |  |             QueryType queryType = default(QueryType); | 
|  | 56 | 353 |  |             if (searchParameters != null) | 
|  |  | 354 |  |             { | 
|  | 56 | 355 |  |                 queryType = searchParameters.QueryType; | 
|  |  | 356 |  |             } | 
|  | 56 | 357 |  |             IList<ScoringParameter> scoringParameters = default(IList<ScoringParameter>); | 
|  | 56 | 358 |  |             if (searchParameters != null) | 
|  |  | 359 |  |             { | 
|  | 56 | 360 |  |                 scoringParameters = searchParameters.ScoringParameters; | 
|  |  | 361 |  |             } | 
|  | 56 | 362 |  |             string scoringProfile = default(string); | 
|  | 56 | 363 |  |             if (searchParameters != null) | 
|  |  | 364 |  |             { | 
|  | 56 | 365 |  |                 scoringProfile = searchParameters.ScoringProfile; | 
|  |  | 366 |  |             } | 
|  | 56 | 367 |  |             IList<string> searchFields = default(IList<string>); | 
|  | 56 | 368 |  |             if (searchParameters != null) | 
|  |  | 369 |  |             { | 
|  | 56 | 370 |  |                 searchFields = searchParameters.SearchFields; | 
|  |  | 371 |  |             } | 
|  | 56 | 372 |  |             SearchMode searchMode = default(SearchMode); | 
|  | 56 | 373 |  |             if (searchParameters != null) | 
|  |  | 374 |  |             { | 
|  | 56 | 375 |  |                 searchMode = searchParameters.SearchMode; | 
|  |  | 376 |  |             } | 
|  | 56 | 377 |  |             IList<string> select = default(IList<string>); | 
|  | 56 | 378 |  |             if (searchParameters != null) | 
|  |  | 379 |  |             { | 
|  | 56 | 380 |  |                 select = searchParameters.Select; | 
|  |  | 381 |  |             } | 
|  | 56 | 382 |  |             int? skip = default(int?); | 
|  | 56 | 383 |  |             if (searchParameters != null) | 
|  |  | 384 |  |             { | 
|  | 56 | 385 |  |                 skip = searchParameters.Skip; | 
|  |  | 386 |  |             } | 
|  | 56 | 387 |  |             int? top = default(int?); | 
|  | 56 | 388 |  |             if (searchParameters != null) | 
|  |  | 389 |  |             { | 
|  | 56 | 390 |  |                 top = searchParameters.Top; | 
|  |  | 391 |  |             } | 
|  | 56 | 392 |  |             System.Guid? clientRequestId = default(System.Guid?); | 
|  | 56 | 393 |  |             if (searchRequestOptions != null) | 
|  |  | 394 |  |             { | 
|  | 0 | 395 |  |                 clientRequestId = searchRequestOptions.ClientRequestId; | 
|  |  | 396 |  |             } | 
|  |  | 397 |  |             // Tracing | 
|  | 56 | 398 |  |             bool _shouldTrace = ServiceClientTracing.IsEnabled; | 
|  | 56 | 399 |  |             string _invocationId = null; | 
|  | 56 | 400 |  |             if (_shouldTrace) | 
|  |  | 401 |  |             { | 
|  | 0 | 402 |  |                 _invocationId = ServiceClientTracing.NextInvocationId.ToString(); | 
|  | 0 | 403 |  |                 Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); | 
|  | 0 | 404 |  |                 tracingParameters.Add("searchText", searchText); | 
|  | 0 | 405 |  |                 tracingParameters.Add("includeTotalResultCount", includeTotalResultCount); | 
|  | 0 | 406 |  |                 tracingParameters.Add("facets", facets); | 
|  | 0 | 407 |  |                 tracingParameters.Add("filter", filter); | 
|  | 0 | 408 |  |                 tracingParameters.Add("highlightFields", highlightFields); | 
|  | 0 | 409 |  |                 tracingParameters.Add("highlightPostTag", highlightPostTag); | 
|  | 0 | 410 |  |                 tracingParameters.Add("highlightPreTag", highlightPreTag); | 
|  | 0 | 411 |  |                 tracingParameters.Add("minimumCoverage", minimumCoverage); | 
|  | 0 | 412 |  |                 tracingParameters.Add("orderBy", orderBy); | 
|  | 0 | 413 |  |                 tracingParameters.Add("queryType", queryType); | 
|  | 0 | 414 |  |                 tracingParameters.Add("scoringParameters", scoringParameters); | 
|  | 0 | 415 |  |                 tracingParameters.Add("scoringProfile", scoringProfile); | 
|  | 0 | 416 |  |                 tracingParameters.Add("searchFields", searchFields); | 
|  | 0 | 417 |  |                 tracingParameters.Add("searchMode", searchMode); | 
|  | 0 | 418 |  |                 tracingParameters.Add("select", select); | 
|  | 0 | 419 |  |                 tracingParameters.Add("skip", skip); | 
|  | 0 | 420 |  |                 tracingParameters.Add("top", top); | 
|  | 0 | 421 |  |                 tracingParameters.Add("clientRequestId", clientRequestId); | 
|  | 0 | 422 |  |                 tracingParameters.Add("cancellationToken", cancellationToken); | 
|  | 0 | 423 |  |                 ServiceClientTracing.Enter(_invocationId, this, "SearchGet", tracingParameters); | 
|  |  | 424 |  |             } | 
|  |  | 425 |  |             // Construct URL | 
|  | 56 | 426 |  |             var _baseUrl = Client.BaseUri; | 
|  | 56 | 427 |  |             var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "docs"; | 
|  | 56 | 428 |  |             _url = _url.Replace("{searchServiceName}", Client.SearchServiceName); | 
|  | 56 | 429 |  |             _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix); | 
|  | 56 | 430 |  |             _url = _url.Replace("{indexName}", Client.IndexName); | 
|  | 56 | 431 |  |             List<string> _queryParameters = new List<string>(); | 
|  | 56 | 432 |  |             if (searchText != null) | 
|  |  | 433 |  |             { | 
|  | 56 | 434 |  |                 _queryParameters.Add(string.Format("search={0}", System.Uri.EscapeDataString(searchText))); | 
|  |  | 435 |  |             } | 
|  | 56 | 436 |  |             if (Client.ApiVersion != null) | 
|  |  | 437 |  |             { | 
|  | 56 | 438 |  |                 _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); | 
|  |  | 439 |  |             } | 
|  | 56 | 440 |  |             _queryParameters.Add(string.Format("$count={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConv | 
|  | 56 | 441 |  |             if (facets != null) | 
|  |  | 442 |  |             { | 
|  | 4 | 443 |  |                 if (facets.Count == 0) | 
|  |  | 444 |  |                 { | 
|  | 0 | 445 |  |                     _queryParameters.Add(string.Format("facet={0}", System.Uri.EscapeDataString(string.Empty))); | 
|  |  | 446 |  |                 } | 
|  |  | 447 |  |                 else | 
|  |  | 448 |  |                 { | 
|  | 40 | 449 |  |                     foreach (var _item in facets) | 
|  |  | 450 |  |                     { | 
|  | 16 | 451 |  |                         _queryParameters.Add(string.Format("facet={0}", System.Uri.EscapeDataString("" + _item))); | 
|  |  | 452 |  |                     } | 
|  |  | 453 |  |                 } | 
|  |  | 454 |  |             } | 
|  | 56 | 455 |  |             if (filter != null) | 
|  |  | 456 |  |             { | 
|  | 10 | 457 |  |                 _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); | 
|  |  | 458 |  |             } | 
|  | 56 | 459 |  |             if (highlightFields != null) | 
|  |  | 460 |  |             { | 
|  | 2 | 461 |  |                 _queryParameters.Add(string.Format("highlight={0}", System.Uri.EscapeDataString(string.Join(",", highlig | 
|  |  | 462 |  |             } | 
|  | 56 | 463 |  |             if (highlightPostTag != null) | 
|  |  | 464 |  |             { | 
|  | 2 | 465 |  |                 _queryParameters.Add(string.Format("highlightPostTag={0}", System.Uri.EscapeDataString(highlightPostTag) | 
|  |  | 466 |  |             } | 
|  | 56 | 467 |  |             if (highlightPreTag != null) | 
|  |  | 468 |  |             { | 
|  | 2 | 469 |  |                 _queryParameters.Add(string.Format("highlightPreTag={0}", System.Uri.EscapeDataString(highlightPreTag))) | 
|  |  | 470 |  |             } | 
|  | 56 | 471 |  |             if (minimumCoverage != null) | 
|  |  | 472 |  |             { | 
|  | 2 | 473 |  |                 _queryParameters.Add(string.Format("minimumCoverage={0}", System.Uri.EscapeDataString(Rest.Serialization | 
|  |  | 474 |  |             } | 
|  | 56 | 475 |  |             if (orderBy != null) | 
|  |  | 476 |  |             { | 
|  | 12 | 477 |  |                 _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(string.Join(",", orderBy) | 
|  |  | 478 |  |             } | 
|  | 56 | 479 |  |             _queryParameters.Add(string.Format("queryType={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonC | 
|  | 56 | 480 |  |             if (scoringParameters != null) | 
|  |  | 481 |  |             { | 
|  | 2 | 482 |  |                 if (scoringParameters.Count == 0) | 
|  |  | 483 |  |                 { | 
|  | 0 | 484 |  |                     _queryParameters.Add(string.Format("scoringParameter={0}", System.Uri.EscapeDataString(string.Empty) | 
|  |  | 485 |  |                 } | 
|  |  | 486 |  |                 else | 
|  |  | 487 |  |                 { | 
|  | 8 | 488 |  |                     foreach (var _item in scoringParameters) | 
|  |  | 489 |  |                     { | 
|  | 2 | 490 |  |                         _queryParameters.Add(string.Format("scoringParameter={0}", System.Uri.EscapeDataString("" + _ite | 
|  |  | 491 |  |                     } | 
|  |  | 492 |  |                 } | 
|  |  | 493 |  |             } | 
|  | 56 | 494 |  |             if (scoringProfile != null) | 
|  |  | 495 |  |             { | 
|  | 2 | 496 |  |                 _queryParameters.Add(string.Format("scoringProfile={0}", System.Uri.EscapeDataString(scoringProfile))); | 
|  |  | 497 |  |             } | 
|  | 56 | 498 |  |             if (searchFields != null) | 
|  |  | 499 |  |             { | 
|  | 4 | 500 |  |                 _queryParameters.Add(string.Format("searchFields={0}", System.Uri.EscapeDataString(string.Join(",", sear | 
|  |  | 501 |  |             } | 
|  | 56 | 502 |  |             _queryParameters.Add(string.Format("searchMode={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJson | 
|  | 56 | 503 |  |             if (select != null) | 
|  |  | 504 |  |             { | 
|  | 14 | 505 |  |                 _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(string.Join(",", select))) | 
|  |  | 506 |  |             } | 
|  | 56 | 507 |  |             if (skip != null) | 
|  |  | 508 |  |             { | 
|  | 4 | 509 |  |                 _queryParameters.Add(string.Format("$skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonC | 
|  |  | 510 |  |             } | 
|  | 56 | 511 |  |             if (top != null) | 
|  |  | 512 |  |             { | 
|  | 10 | 513 |  |                 _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo | 
|  |  | 514 |  |             } | 
|  | 56 | 515 |  |             if (_queryParameters.Count > 0) | 
|  |  | 516 |  |             { | 
|  | 56 | 517 |  |                 _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); | 
|  |  | 518 |  |             } | 
|  | 56 | 519 |  |             return await ContinueSearchGetWithHttpMessagesAsync<T>(_url, clientRequestId, customHeaders, _shouldTrace, _ | 
|  | 52 | 520 |  |         } | 
|  |  | 521 |  |  | 
|  |  | 522 |  |         public async Task<AzureOperationResponse<DocumentSearchResult<T>>> ContinueSearchGetWithHttpMessagesAsync<T>(str | 
|  |  | 523 |  |         { | 
|  |  | 524 |  |             // Create HTTP transport objects | 
|  | 72 | 525 |  |             var _httpRequest = new HttpRequestMessage(); | 
|  | 72 | 526 |  |             HttpResponseMessage _httpResponse = null; | 
|  | 72 | 527 |  |             _httpRequest.Method = new HttpMethod("GET"); | 
|  | 72 | 528 |  |             _httpRequest.RequestUri = new System.Uri(_url); | 
|  |  | 529 |  |             // Set Headers | 
|  | 72 | 530 |  |             if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) | 
|  |  | 531 |  |             { | 
|  | 72 | 532 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); | 
|  |  | 533 |  |             } | 
|  | 72 | 534 |  |             if (Client.AcceptLanguage != null) | 
|  |  | 535 |  |             { | 
|  | 72 | 536 |  |                 if (_httpRequest.Headers.Contains("accept-language")) | 
|  |  | 537 |  |                 { | 
|  | 0 | 538 |  |                     _httpRequest.Headers.Remove("accept-language"); | 
|  |  | 539 |  |                 } | 
|  | 72 | 540 |  |                 _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); | 
|  |  | 541 |  |             } | 
|  | 72 | 542 |  |             if (clientRequestId != null) | 
|  |  | 543 |  |             { | 
|  | 0 | 544 |  |                 if (_httpRequest.Headers.Contains("client-request-id")) | 
|  |  | 545 |  |                 { | 
|  | 0 | 546 |  |                     _httpRequest.Headers.Remove("client-request-id"); | 
|  |  | 547 |  |                 } | 
|  | 0 | 548 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser | 
|  |  | 549 |  |             } | 
|  |  | 550 |  |  | 
|  |  | 551 |  |  | 
|  | 72 | 552 |  |             if (customHeaders != null) | 
|  |  | 553 |  |             { | 
|  | 288 | 554 |  |                 foreach(var _header in customHeaders) | 
|  |  | 555 |  |                 { | 
|  | 72 | 556 |  |                     if (_httpRequest.Headers.Contains(_header.Key)) | 
|  |  | 557 |  |                     { | 
|  | 0 | 558 |  |                         _httpRequest.Headers.Remove(_header.Key); | 
|  |  | 559 |  |                     } | 
|  | 72 | 560 |  |                     _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); | 
|  |  | 561 |  |                 } | 
|  |  | 562 |  |             } | 
|  |  | 563 |  |  | 
|  |  | 564 |  |             // Serialize Request | 
|  | 72 | 565 |  |             string _requestContent = null; | 
|  |  | 566 |  |             // Set Credentials | 
|  | 72 | 567 |  |             if (Client.Credentials != null) | 
|  |  | 568 |  |             { | 
|  | 72 | 569 |  |                 cancellationToken.ThrowIfCancellationRequested(); | 
|  | 72 | 570 |  |                 await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  |  | 571 |  |             } | 
|  |  | 572 |  |             // Send Request | 
|  | 72 | 573 |  |             if (_shouldTrace) | 
|  |  | 574 |  |             { | 
|  | 0 | 575 |  |                 ServiceClientTracing.SendRequest(_invocationId, _httpRequest); | 
|  |  | 576 |  |             } | 
|  | 72 | 577 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 72 | 578 |  |             _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  | 72 | 579 |  |             if (_shouldTrace) | 
|  |  | 580 |  |             { | 
|  | 0 | 581 |  |                 ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); | 
|  |  | 582 |  |             } | 
|  | 72 | 583 |  |             HttpStatusCode _statusCode = _httpResponse.StatusCode; | 
|  | 72 | 584 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 72 | 585 |  |             string _responseContent = null; | 
|  | 72 | 586 |  |             if ((int)_statusCode != 200) | 
|  |  | 587 |  |             { | 
|  | 4 | 588 |  |                 var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode | 
|  |  | 589 |  |                 try | 
|  |  | 590 |  |                 { | 
|  | 4 | 591 |  |                     _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  | 4 | 592 |  |                     CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC | 
|  | 4 | 593 |  |                     if (_errorBody != null) | 
|  |  | 594 |  |                     { | 
|  | 4 | 595 |  |                         ex = new CloudException(_errorBody.Message); | 
|  | 4 | 596 |  |                         ex.Body = _errorBody; | 
|  |  | 597 |  |                     } | 
|  | 4 | 598 |  |                 } | 
|  | 0 | 599 |  |                 catch (JsonException) | 
|  |  | 600 |  |                 { | 
|  |  | 601 |  |                     // Ignore the exception | 
|  | 0 | 602 |  |                 } | 
|  | 4 | 603 |  |                 ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); | 
|  | 4 | 604 |  |                 ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); | 
|  | 4 | 605 |  |                 if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 606 |  |                 { | 
|  | 4 | 607 |  |                     ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 608 |  |                 } | 
|  | 4 | 609 |  |                 if (_shouldTrace) | 
|  |  | 610 |  |                 { | 
|  | 0 | 611 |  |                     ServiceClientTracing.Error(_invocationId, ex); | 
|  |  | 612 |  |                 } | 
|  | 4 | 613 |  |                 _httpRequest.Dispose(); | 
|  | 4 | 614 |  |                 if (_httpResponse != null) | 
|  |  | 615 |  |                 { | 
|  | 4 | 616 |  |                     _httpResponse.Dispose(); | 
|  |  | 617 |  |                 } | 
|  | 4 | 618 |  |                 throw ex; | 
|  |  | 619 |  |             } | 
|  |  | 620 |  |             // Create Result | 
|  | 68 | 621 |  |             var _result = new AzureOperationResponse<DocumentSearchResult<T>>(); | 
|  | 68 | 622 |  |             _result.Request = _httpRequest; | 
|  | 68 | 623 |  |             _result.Response = _httpResponse; | 
|  | 68 | 624 |  |             if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 625 |  |             { | 
|  | 68 | 626 |  |                 _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 627 |  |             } | 
|  |  | 628 |  |             // Deserialize Response | 
|  | 68 | 629 |  |             if ((int)_statusCode == 200) | 
|  |  | 630 |  |             { | 
|  | 68 | 631 |  |                 _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  |  | 632 |  |                 try | 
|  |  | 633 |  |                 { | 
|  | 68 | 634 |  |                     _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<DocumentSearchResult<T>>(_respon | 
|  | 68 | 635 |  |                 } | 
|  | 0 | 636 |  |                 catch (JsonException ex) | 
|  |  | 637 |  |                 { | 
|  | 0 | 638 |  |                     _httpRequest.Dispose(); | 
|  | 0 | 639 |  |                     if (_httpResponse != null) | 
|  |  | 640 |  |                     { | 
|  | 0 | 641 |  |                         _httpResponse.Dispose(); | 
|  |  | 642 |  |                     } | 
|  | 0 | 643 |  |                     throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); | 
|  |  | 644 |  |                 } | 
|  |  | 645 |  |             } | 
|  | 68 | 646 |  |             if (_shouldTrace) | 
|  |  | 647 |  |             { | 
|  | 0 | 648 |  |                 ServiceClientTracing.Exit(_invocationId, _result); | 
|  |  | 649 |  |             } | 
|  | 68 | 650 |  |             return _result; | 
|  | 68 | 651 |  |         } | 
|  |  | 652 |  |  | 
|  |  | 653 |  |         /// <summary> | 
|  |  | 654 |  |         /// Searches for documents in the index. | 
|  |  | 655 |  |         /// <see href="https://docs.microsoft.com/rest/api/searchservice/Search-Documents" /> | 
|  |  | 656 |  |         /// </summary> | 
|  |  | 657 |  |         /// <param name='searchRequest'> | 
|  |  | 658 |  |         /// The definition of the Search request. | 
|  |  | 659 |  |         /// </param> | 
|  |  | 660 |  |         /// <param name='searchRequestOptions'> | 
|  |  | 661 |  |         /// Additional parameters for the operation | 
|  |  | 662 |  |         /// </param> | 
|  |  | 663 |  |         /// <param name='customHeaders'> | 
|  |  | 664 |  |         /// Headers that will be added to request. | 
|  |  | 665 |  |         /// </param> | 
|  |  | 666 |  |         /// <param name='cancellationToken'> | 
|  |  | 667 |  |         /// The cancellation token. | 
|  |  | 668 |  |         /// </param> | 
|  |  | 669 |  |         /// <exception cref="CloudException"> | 
|  |  | 670 |  |         /// Thrown when the operation returned an invalid status code | 
|  |  | 671 |  |         /// </exception> | 
|  |  | 672 |  |         /// <exception cref="SerializationException"> | 
|  |  | 673 |  |         /// Thrown when unable to deserialize the response | 
|  |  | 674 |  |         /// </exception> | 
|  |  | 675 |  |         /// <exception cref="ValidationException"> | 
|  |  | 676 |  |         /// Thrown when a required parameter is null | 
|  |  | 677 |  |         /// </exception> | 
|  |  | 678 |  |         /// <exception cref="System.ArgumentNullException"> | 
|  |  | 679 |  |         /// Thrown when a required parameter is null | 
|  |  | 680 |  |         /// </exception> | 
|  |  | 681 |  |         /// <return> | 
|  |  | 682 |  |         /// A response object containing the response body and response headers. | 
|  |  | 683 |  |         /// </return> | 
|  |  | 684 |  |         public async Task<AzureOperationResponse<DocumentSearchResult<T>>> SearchPostWithHttpMessagesAsync<T>(SearchRequ | 
|  |  | 685 |  |         { | 
|  | 86 | 686 |  |             if (Client.SearchServiceName == null) | 
|  |  | 687 |  |             { | 
|  | 0 | 688 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName"); | 
|  |  | 689 |  |             } | 
|  | 86 | 690 |  |             if (Client.SearchDnsSuffix == null) | 
|  |  | 691 |  |             { | 
|  | 0 | 692 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix"); | 
|  |  | 693 |  |             } | 
|  | 86 | 694 |  |             if (Client.IndexName == null) | 
|  |  | 695 |  |             { | 
|  | 0 | 696 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.IndexName"); | 
|  |  | 697 |  |             } | 
|  | 86 | 698 |  |             if (searchRequest == null) | 
|  |  | 699 |  |             { | 
|  | 0 | 700 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "searchRequest"); | 
|  |  | 701 |  |             } | 
|  | 86 | 702 |  |             if (Client.ApiVersion == null) | 
|  |  | 703 |  |             { | 
|  | 0 | 704 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); | 
|  |  | 705 |  |             } | 
|  | 86 | 706 |  |             System.Guid? clientRequestId = default(System.Guid?); | 
|  | 86 | 707 |  |             if (searchRequestOptions != null) | 
|  |  | 708 |  |             { | 
|  | 0 | 709 |  |                 clientRequestId = searchRequestOptions.ClientRequestId; | 
|  |  | 710 |  |             } | 
|  |  | 711 |  |             // Tracing | 
|  | 86 | 712 |  |             bool _shouldTrace = ServiceClientTracing.IsEnabled; | 
|  | 86 | 713 |  |             string _invocationId = null; | 
|  | 86 | 714 |  |             if (_shouldTrace) | 
|  |  | 715 |  |             { | 
|  | 0 | 716 |  |                 _invocationId = ServiceClientTracing.NextInvocationId.ToString(); | 
|  | 0 | 717 |  |                 Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); | 
|  | 0 | 718 |  |                 tracingParameters.Add("searchRequest", searchRequest); | 
|  | 0 | 719 |  |                 tracingParameters.Add("clientRequestId", clientRequestId); | 
|  | 0 | 720 |  |                 tracingParameters.Add("cancellationToken", cancellationToken); | 
|  | 0 | 721 |  |                 ServiceClientTracing.Enter(_invocationId, this, "SearchPost", tracingParameters); | 
|  |  | 722 |  |             } | 
|  |  | 723 |  |             // Construct URL | 
|  | 86 | 724 |  |             var _baseUrl = Client.BaseUri; | 
|  | 86 | 725 |  |             var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "docs/search.post.search"; | 
|  | 86 | 726 |  |             _url = _url.Replace("{searchServiceName}", Client.SearchServiceName); | 
|  | 86 | 727 |  |             _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix); | 
|  | 86 | 728 |  |             _url = _url.Replace("{indexName}", Client.IndexName); | 
|  | 86 | 729 |  |             List<string> _queryParameters = new List<string>(); | 
|  | 86 | 730 |  |             if (Client.ApiVersion != null) | 
|  |  | 731 |  |             { | 
|  | 86 | 732 |  |                 _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); | 
|  |  | 733 |  |             } | 
|  | 86 | 734 |  |             if (_queryParameters.Count > 0) | 
|  |  | 735 |  |             { | 
|  | 86 | 736 |  |                 _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); | 
|  |  | 737 |  |             } | 
|  | 86 | 738 |  |             return await ContinueSearchPostWithHttpMessagesAsync<T>(_url, searchRequest, clientRequestId, customHeaders, | 
|  | 74 | 739 |  |         } | 
|  |  | 740 |  |  | 
|  |  | 741 |  |         public async Task<AzureOperationResponse<DocumentSearchResult<T>>> ContinueSearchPostWithHttpMessagesAsync<T>(st | 
|  |  | 742 |  |         { | 
|  |  | 743 |  |             // Create HTTP transport objects | 
|  | 102 | 744 |  |             var _httpRequest = new HttpRequestMessage(); | 
|  | 102 | 745 |  |             HttpResponseMessage _httpResponse = null; | 
|  | 102 | 746 |  |             _httpRequest.Method = new HttpMethod("POST"); | 
|  | 102 | 747 |  |             _httpRequest.RequestUri = new System.Uri(_url); | 
|  |  | 748 |  |             // Set Headers | 
|  | 102 | 749 |  |             if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) | 
|  |  | 750 |  |             { | 
|  | 102 | 751 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); | 
|  |  | 752 |  |             } | 
|  | 102 | 753 |  |             if (Client.AcceptLanguage != null) | 
|  |  | 754 |  |             { | 
|  | 102 | 755 |  |                 if (_httpRequest.Headers.Contains("accept-language")) | 
|  |  | 756 |  |                 { | 
|  | 0 | 757 |  |                     _httpRequest.Headers.Remove("accept-language"); | 
|  |  | 758 |  |                 } | 
|  | 102 | 759 |  |                 _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); | 
|  |  | 760 |  |             } | 
|  | 102 | 761 |  |             if (clientRequestId != null) | 
|  |  | 762 |  |             { | 
|  | 0 | 763 |  |                 if (_httpRequest.Headers.Contains("client-request-id")) | 
|  |  | 764 |  |                 { | 
|  | 0 | 765 |  |                     _httpRequest.Headers.Remove("client-request-id"); | 
|  |  | 766 |  |                 } | 
|  | 0 | 767 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser | 
|  |  | 768 |  |             } | 
|  |  | 769 |  |  | 
|  |  | 770 |  |  | 
|  | 102 | 771 |  |             if (customHeaders != null) | 
|  |  | 772 |  |             { | 
|  | 408 | 773 |  |                 foreach(var _header in customHeaders) | 
|  |  | 774 |  |                 { | 
|  | 102 | 775 |  |                     if (_httpRequest.Headers.Contains(_header.Key)) | 
|  |  | 776 |  |                     { | 
|  | 0 | 777 |  |                         _httpRequest.Headers.Remove(_header.Key); | 
|  |  | 778 |  |                     } | 
|  | 102 | 779 |  |                     _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); | 
|  |  | 780 |  |                 } | 
|  |  | 781 |  |             } | 
|  |  | 782 |  |  | 
|  |  | 783 |  |             // Serialize Request | 
|  | 102 | 784 |  |             string _requestContent = null; | 
|  | 102 | 785 |  |             if(searchRequest != null) | 
|  |  | 786 |  |             { | 
|  | 102 | 787 |  |                 _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(searchRequest, requestSerializerSet | 
|  | 102 | 788 |  |                 _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); | 
|  | 102 | 789 |  |                 _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio | 
|  |  | 790 |  |             } | 
|  |  | 791 |  |             // Set Credentials | 
|  | 102 | 792 |  |             if (Client.Credentials != null) | 
|  |  | 793 |  |             { | 
|  | 102 | 794 |  |                 cancellationToken.ThrowIfCancellationRequested(); | 
|  | 102 | 795 |  |                 await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  |  | 796 |  |             } | 
|  |  | 797 |  |             // Send Request | 
|  | 102 | 798 |  |             if (_shouldTrace) | 
|  |  | 799 |  |             { | 
|  | 0 | 800 |  |                 ServiceClientTracing.SendRequest(_invocationId, _httpRequest); | 
|  |  | 801 |  |             } | 
|  | 102 | 802 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 102 | 803 |  |             _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  | 102 | 804 |  |             if (_shouldTrace) | 
|  |  | 805 |  |             { | 
|  | 0 | 806 |  |                 ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); | 
|  |  | 807 |  |             } | 
|  | 102 | 808 |  |             HttpStatusCode _statusCode = _httpResponse.StatusCode; | 
|  | 102 | 809 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 102 | 810 |  |             string _responseContent = null; | 
|  | 102 | 811 |  |             if ((int)_statusCode != 200) | 
|  |  | 812 |  |             { | 
|  | 4 | 813 |  |                 var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode | 
|  |  | 814 |  |                 try | 
|  |  | 815 |  |                 { | 
|  | 4 | 816 |  |                     _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  | 4 | 817 |  |                     CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC | 
|  | 4 | 818 |  |                     if (_errorBody != null) | 
|  |  | 819 |  |                     { | 
|  | 4 | 820 |  |                         ex = new CloudException(_errorBody.Message); | 
|  | 4 | 821 |  |                         ex.Body = _errorBody; | 
|  |  | 822 |  |                     } | 
|  | 4 | 823 |  |                 } | 
|  | 0 | 824 |  |                 catch (JsonException) | 
|  |  | 825 |  |                 { | 
|  |  | 826 |  |                     // Ignore the exception | 
|  | 0 | 827 |  |                 } | 
|  | 4 | 828 |  |                 ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); | 
|  | 4 | 829 |  |                 ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); | 
|  | 4 | 830 |  |                 if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 831 |  |                 { | 
|  | 4 | 832 |  |                     ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 833 |  |                 } | 
|  | 4 | 834 |  |                 if (_shouldTrace) | 
|  |  | 835 |  |                 { | 
|  | 0 | 836 |  |                     ServiceClientTracing.Error(_invocationId, ex); | 
|  |  | 837 |  |                 } | 
|  | 4 | 838 |  |                 _httpRequest.Dispose(); | 
|  | 4 | 839 |  |                 if (_httpResponse != null) | 
|  |  | 840 |  |                 { | 
|  | 4 | 841 |  |                     _httpResponse.Dispose(); | 
|  |  | 842 |  |                 } | 
|  | 4 | 843 |  |                 throw ex; | 
|  |  | 844 |  |             } | 
|  |  | 845 |  |             // Create Result | 
|  | 98 | 846 |  |             var _result = new AzureOperationResponse<DocumentSearchResult<T>>(); | 
|  | 98 | 847 |  |             _result.Request = _httpRequest; | 
|  | 98 | 848 |  |             _result.Response = _httpResponse; | 
|  | 98 | 849 |  |             if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 850 |  |             { | 
|  | 98 | 851 |  |                 _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 852 |  |             } | 
|  |  | 853 |  |             // Deserialize Response | 
|  | 98 | 854 |  |             if ((int)_statusCode == 200) | 
|  |  | 855 |  |             { | 
|  | 98 | 856 |  |                 _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  |  | 857 |  |                 try | 
|  |  | 858 |  |                 { | 
|  | 98 | 859 |  |                     _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<DocumentSearchResult<T>>(_respon | 
|  | 90 | 860 |  |                 } | 
|  | 8 | 861 |  |                 catch (JsonException ex) | 
|  |  | 862 |  |                 { | 
|  | 8 | 863 |  |                     _httpRequest.Dispose(); | 
|  | 8 | 864 |  |                     if (_httpResponse != null) | 
|  |  | 865 |  |                     { | 
|  | 8 | 866 |  |                         _httpResponse.Dispose(); | 
|  |  | 867 |  |                     } | 
|  | 8 | 868 |  |                     throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); | 
|  |  | 869 |  |                 } | 
|  |  | 870 |  |             } | 
|  | 90 | 871 |  |             if (_shouldTrace) | 
|  |  | 872 |  |             { | 
|  | 0 | 873 |  |                 ServiceClientTracing.Exit(_invocationId, _result); | 
|  |  | 874 |  |             } | 
|  | 90 | 875 |  |             return _result; | 
|  | 90 | 876 |  |         } | 
|  |  | 877 |  |  | 
|  |  | 878 |  |         /// <summary> | 
|  |  | 879 |  |         /// Retrieves a document from the index. | 
|  |  | 880 |  |         /// <see href="https://docs.microsoft.com/rest/api/searchservice/lookup-document" /> | 
|  |  | 881 |  |         /// </summary> | 
|  |  | 882 |  |         /// <param name='key'> | 
|  |  | 883 |  |         /// The key of the document to retrieve. | 
|  |  | 884 |  |         /// </param> | 
|  |  | 885 |  |         /// <param name='selectedFields'> | 
|  |  | 886 |  |         /// List of field names to retrieve for the document; Any field not retrieved | 
|  |  | 887 |  |         /// will be missing from the returned document. | 
|  |  | 888 |  |         /// </param> | 
|  |  | 889 |  |         /// <param name='searchRequestOptions'> | 
|  |  | 890 |  |         /// Additional parameters for the operation | 
|  |  | 891 |  |         /// </param> | 
|  |  | 892 |  |         /// <param name='customHeaders'> | 
|  |  | 893 |  |         /// Headers that will be added to request. | 
|  |  | 894 |  |         /// </param> | 
|  |  | 895 |  |         /// <param name='cancellationToken'> | 
|  |  | 896 |  |         /// The cancellation token. | 
|  |  | 897 |  |         /// </param> | 
|  |  | 898 |  |         /// <exception cref="CloudException"> | 
|  |  | 899 |  |         /// Thrown when the operation returned an invalid status code | 
|  |  | 900 |  |         /// </exception> | 
|  |  | 901 |  |         /// <exception cref="SerializationException"> | 
|  |  | 902 |  |         /// Thrown when unable to deserialize the response | 
|  |  | 903 |  |         /// </exception> | 
|  |  | 904 |  |         /// <exception cref="ValidationException"> | 
|  |  | 905 |  |         /// Thrown when a required parameter is null | 
|  |  | 906 |  |         /// </exception> | 
|  |  | 907 |  |         /// <exception cref="System.ArgumentNullException"> | 
|  |  | 908 |  |         /// Thrown when a required parameter is null | 
|  |  | 909 |  |         /// </exception> | 
|  |  | 910 |  |         /// <return> | 
|  |  | 911 |  |         /// A response object containing the response body and response headers. | 
|  |  | 912 |  |         /// </return> | 
|  |  | 913 |  |         public async Task<AzureOperationResponse<T>> GetWithHttpMessagesAsync<T>(string key, IList<string> selectedField | 
|  |  | 914 |  |         { | 
|  | 80 | 915 |  |             if (Client.SearchServiceName == null) | 
|  |  | 916 |  |             { | 
|  | 0 | 917 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName"); | 
|  |  | 918 |  |             } | 
|  | 80 | 919 |  |             if (Client.SearchDnsSuffix == null) | 
|  |  | 920 |  |             { | 
|  | 0 | 921 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix"); | 
|  |  | 922 |  |             } | 
|  | 80 | 923 |  |             if (Client.IndexName == null) | 
|  |  | 924 |  |             { | 
|  | 0 | 925 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.IndexName"); | 
|  |  | 926 |  |             } | 
|  | 80 | 927 |  |             if (key == null) | 
|  |  | 928 |  |             { | 
|  | 0 | 929 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "key"); | 
|  |  | 930 |  |             } | 
|  | 80 | 931 |  |             if (Client.ApiVersion == null) | 
|  |  | 932 |  |             { | 
|  | 0 | 933 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); | 
|  |  | 934 |  |             } | 
|  | 80 | 935 |  |             System.Guid? clientRequestId = default(System.Guid?); | 
|  | 80 | 936 |  |             if (searchRequestOptions != null) | 
|  |  | 937 |  |             { | 
|  | 0 | 938 |  |                 clientRequestId = searchRequestOptions.ClientRequestId; | 
|  |  | 939 |  |             } | 
|  |  | 940 |  |             // Tracing | 
|  | 80 | 941 |  |             bool _shouldTrace = ServiceClientTracing.IsEnabled; | 
|  | 80 | 942 |  |             string _invocationId = null; | 
|  | 80 | 943 |  |             if (_shouldTrace) | 
|  |  | 944 |  |             { | 
|  | 0 | 945 |  |                 _invocationId = ServiceClientTracing.NextInvocationId.ToString(); | 
|  | 0 | 946 |  |                 Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); | 
|  | 0 | 947 |  |                 tracingParameters.Add("key", key); | 
|  | 0 | 948 |  |                 tracingParameters.Add("selectedFields", selectedFields); | 
|  | 0 | 949 |  |                 tracingParameters.Add("clientRequestId", clientRequestId); | 
|  | 0 | 950 |  |                 tracingParameters.Add("cancellationToken", cancellationToken); | 
|  | 0 | 951 |  |                 ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); | 
|  |  | 952 |  |             } | 
|  |  | 953 |  |             // Construct URL | 
|  | 80 | 954 |  |             var _baseUrl = Client.BaseUri; | 
|  | 80 | 955 |  |             var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "docs('{key}')"; | 
|  | 80 | 956 |  |             _url = _url.Replace("{searchServiceName}", Client.SearchServiceName); | 
|  | 80 | 957 |  |             _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix); | 
|  | 80 | 958 |  |             _url = _url.Replace("{indexName}", Client.IndexName); | 
|  | 80 | 959 |  |             _url = _url.Replace("{key}", System.Uri.EscapeDataString(key)); | 
|  | 80 | 960 |  |             List<string> _queryParameters = new List<string>(); | 
|  | 80 | 961 |  |             if (selectedFields != null) | 
|  |  | 962 |  |             { | 
|  | 80 | 963 |  |                 _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(string.Join(",", selectedF | 
|  |  | 964 |  |             } | 
|  | 80 | 965 |  |             if (Client.ApiVersion != null) | 
|  |  | 966 |  |             { | 
|  | 80 | 967 |  |                 _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); | 
|  |  | 968 |  |             } | 
|  | 80 | 969 |  |             if (_queryParameters.Count > 0) | 
|  |  | 970 |  |             { | 
|  | 80 | 971 |  |                 _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); | 
|  |  | 972 |  |             } | 
|  |  | 973 |  |             // Create HTTP transport objects | 
|  | 80 | 974 |  |             var _httpRequest = new HttpRequestMessage(); | 
|  | 80 | 975 |  |             HttpResponseMessage _httpResponse = null; | 
|  | 80 | 976 |  |             _httpRequest.Method = new HttpMethod("GET"); | 
|  | 80 | 977 |  |             _httpRequest.RequestUri = new System.Uri(_url); | 
|  |  | 978 |  |             // Set Headers | 
|  | 80 | 979 |  |             if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) | 
|  |  | 980 |  |             { | 
|  | 80 | 981 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); | 
|  |  | 982 |  |             } | 
|  | 80 | 983 |  |             if (Client.AcceptLanguage != null) | 
|  |  | 984 |  |             { | 
|  | 80 | 985 |  |                 if (_httpRequest.Headers.Contains("accept-language")) | 
|  |  | 986 |  |                 { | 
|  | 0 | 987 |  |                     _httpRequest.Headers.Remove("accept-language"); | 
|  |  | 988 |  |                 } | 
|  | 80 | 989 |  |                 _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); | 
|  |  | 990 |  |             } | 
|  | 80 | 991 |  |             if (clientRequestId != null) | 
|  |  | 992 |  |             { | 
|  | 0 | 993 |  |                 if (_httpRequest.Headers.Contains("client-request-id")) | 
|  |  | 994 |  |                 { | 
|  | 0 | 995 |  |                     _httpRequest.Headers.Remove("client-request-id"); | 
|  |  | 996 |  |                 } | 
|  | 0 | 997 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser | 
|  |  | 998 |  |             } | 
|  |  | 999 |  |  | 
|  |  | 1000 |  |  | 
|  | 80 | 1001 |  |             if (customHeaders != null) | 
|  |  | 1002 |  |             { | 
|  | 320 | 1003 |  |                 foreach(var _header in customHeaders) | 
|  |  | 1004 |  |                 { | 
|  | 80 | 1005 |  |                     if (_httpRequest.Headers.Contains(_header.Key)) | 
|  |  | 1006 |  |                     { | 
|  | 0 | 1007 |  |                         _httpRequest.Headers.Remove(_header.Key); | 
|  |  | 1008 |  |                     } | 
|  | 80 | 1009 |  |                     _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); | 
|  |  | 1010 |  |                 } | 
|  |  | 1011 |  |             } | 
|  |  | 1012 |  |  | 
|  |  | 1013 |  |             // Serialize Request | 
|  | 80 | 1014 |  |             string _requestContent = null; | 
|  |  | 1015 |  |             // Set Credentials | 
|  | 80 | 1016 |  |             if (Client.Credentials != null) | 
|  |  | 1017 |  |             { | 
|  | 80 | 1018 |  |                 cancellationToken.ThrowIfCancellationRequested(); | 
|  | 80 | 1019 |  |                 await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  |  | 1020 |  |             } | 
|  |  | 1021 |  |             // Send Request | 
|  | 80 | 1022 |  |             if (_shouldTrace) | 
|  |  | 1023 |  |             { | 
|  | 0 | 1024 |  |                 ServiceClientTracing.SendRequest(_invocationId, _httpRequest); | 
|  |  | 1025 |  |             } | 
|  | 80 | 1026 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 80 | 1027 |  |             _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  | 80 | 1028 |  |             if (_shouldTrace) | 
|  |  | 1029 |  |             { | 
|  | 0 | 1030 |  |                 ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); | 
|  |  | 1031 |  |             } | 
|  | 80 | 1032 |  |             HttpStatusCode _statusCode = _httpResponse.StatusCode; | 
|  | 80 | 1033 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 80 | 1034 |  |             string _responseContent = null; | 
|  | 80 | 1035 |  |             if ((int)_statusCode != 200) | 
|  |  | 1036 |  |             { | 
|  | 4 | 1037 |  |                 var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode | 
|  |  | 1038 |  |                 try | 
|  |  | 1039 |  |                 { | 
|  | 4 | 1040 |  |                     _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  | 4 | 1041 |  |                     CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC | 
|  | 4 | 1042 |  |                     if (_errorBody != null) | 
|  |  | 1043 |  |                     { | 
|  | 2 | 1044 |  |                         ex = new CloudException(_errorBody.Message); | 
|  | 2 | 1045 |  |                         ex.Body = _errorBody; | 
|  |  | 1046 |  |                     } | 
|  | 4 | 1047 |  |                 } | 
|  | 0 | 1048 |  |                 catch (JsonException) | 
|  |  | 1049 |  |                 { | 
|  |  | 1050 |  |                     // Ignore the exception | 
|  | 0 | 1051 |  |                 } | 
|  | 4 | 1052 |  |                 ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); | 
|  | 4 | 1053 |  |                 ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); | 
|  | 4 | 1054 |  |                 if (_httpResponse.Headers.Contains("x-ms-request-id")) | 
|  |  | 1055 |  |                 { | 
|  | 0 | 1056 |  |                     ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); | 
|  |  | 1057 |  |                 } | 
|  | 4 | 1058 |  |                 if (_shouldTrace) | 
|  |  | 1059 |  |                 { | 
|  | 0 | 1060 |  |                     ServiceClientTracing.Error(_invocationId, ex); | 
|  |  | 1061 |  |                 } | 
|  | 4 | 1062 |  |                 _httpRequest.Dispose(); | 
|  | 4 | 1063 |  |                 if (_httpResponse != null) | 
|  |  | 1064 |  |                 { | 
|  | 4 | 1065 |  |                     _httpResponse.Dispose(); | 
|  |  | 1066 |  |                 } | 
|  | 4 | 1067 |  |                 throw ex; | 
|  |  | 1068 |  |             } | 
|  |  | 1069 |  |             // Create Result | 
|  | 76 | 1070 |  |             var _result = new AzureOperationResponse<T>(); | 
|  | 76 | 1071 |  |             _result.Request = _httpRequest; | 
|  | 76 | 1072 |  |             _result.Response = _httpResponse; | 
|  | 76 | 1073 |  |             if (_httpResponse.Headers.Contains("x-ms-request-id")) | 
|  |  | 1074 |  |             { | 
|  | 0 | 1075 |  |                 _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); | 
|  |  | 1076 |  |             } | 
|  |  | 1077 |  |             // Deserialize Response | 
|  | 76 | 1078 |  |             if ((int)_statusCode == 200) | 
|  |  | 1079 |  |             { | 
|  | 76 | 1080 |  |                 _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  |  | 1081 |  |                 try | 
|  |  | 1082 |  |                 { | 
|  | 76 | 1083 |  |                     _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<T>(_responseContent, responseDes | 
|  | 76 | 1084 |  |                 } | 
|  | 0 | 1085 |  |                 catch (JsonException ex) | 
|  |  | 1086 |  |                 { | 
|  | 0 | 1087 |  |                     _httpRequest.Dispose(); | 
|  | 0 | 1088 |  |                     if (_httpResponse != null) | 
|  |  | 1089 |  |                     { | 
|  | 0 | 1090 |  |                         _httpResponse.Dispose(); | 
|  |  | 1091 |  |                     } | 
|  | 0 | 1092 |  |                     throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); | 
|  |  | 1093 |  |                 } | 
|  |  | 1094 |  |             } | 
|  | 76 | 1095 |  |             if (_shouldTrace) | 
|  |  | 1096 |  |             { | 
|  | 0 | 1097 |  |                 ServiceClientTracing.Exit(_invocationId, _result); | 
|  |  | 1098 |  |             } | 
|  | 76 | 1099 |  |             return _result; | 
|  | 76 | 1100 |  |         } | 
|  |  | 1101 |  |  | 
|  |  | 1102 |  |         /// <summary> | 
|  |  | 1103 |  |         /// Suggests documents in the index that match the given partial query text. | 
|  |  | 1104 |  |         /// <see href="https://docs.microsoft.com/rest/api/searchservice/suggestions" /> | 
|  |  | 1105 |  |         /// </summary> | 
|  |  | 1106 |  |         /// <param name='searchText'> | 
|  |  | 1107 |  |         /// The search text to use to suggest documents. Must be at least 1 character, | 
|  |  | 1108 |  |         /// and no more than 100 characters. | 
|  |  | 1109 |  |         /// </param> | 
|  |  | 1110 |  |         /// <param name='suggesterName'> | 
|  |  | 1111 |  |         /// The name of the suggester as specified in the suggesters collection that's | 
|  |  | 1112 |  |         /// part of the index definition. | 
|  |  | 1113 |  |         /// </param> | 
|  |  | 1114 |  |         /// <param name='suggestParameters'> | 
|  |  | 1115 |  |         /// Additional parameters for the operation | 
|  |  | 1116 |  |         /// </param> | 
|  |  | 1117 |  |         /// <param name='searchRequestOptions'> | 
|  |  | 1118 |  |         /// Additional parameters for the operation | 
|  |  | 1119 |  |         /// </param> | 
|  |  | 1120 |  |         /// <param name='customHeaders'> | 
|  |  | 1121 |  |         /// Headers that will be added to request. | 
|  |  | 1122 |  |         /// </param> | 
|  |  | 1123 |  |         /// <param name='cancellationToken'> | 
|  |  | 1124 |  |         /// The cancellation token. | 
|  |  | 1125 |  |         /// </param> | 
|  |  | 1126 |  |         /// <exception cref="CloudException"> | 
|  |  | 1127 |  |         /// Thrown when the operation returned an invalid status code | 
|  |  | 1128 |  |         /// </exception> | 
|  |  | 1129 |  |         /// <exception cref="SerializationException"> | 
|  |  | 1130 |  |         /// Thrown when unable to deserialize the response | 
|  |  | 1131 |  |         /// </exception> | 
|  |  | 1132 |  |         /// <exception cref="ValidationException"> | 
|  |  | 1133 |  |         /// Thrown when a required parameter is null | 
|  |  | 1134 |  |         /// </exception> | 
|  |  | 1135 |  |         /// <exception cref="System.ArgumentNullException"> | 
|  |  | 1136 |  |         /// Thrown when a required parameter is null | 
|  |  | 1137 |  |         /// </exception> | 
|  |  | 1138 |  |         /// <return> | 
|  |  | 1139 |  |         /// A response object containing the response body and response headers. | 
|  |  | 1140 |  |         /// </return> | 
|  |  | 1141 |  |         public async Task<AzureOperationResponse<DocumentSuggestResult<T>>> SuggestGetWithHttpMessagesAsync<T>(string se | 
|  |  | 1142 |  |         { | 
|  | 30 | 1143 |  |             if (Client.SearchServiceName == null) | 
|  |  | 1144 |  |             { | 
|  | 0 | 1145 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName"); | 
|  |  | 1146 |  |             } | 
|  | 30 | 1147 |  |             if (Client.SearchDnsSuffix == null) | 
|  |  | 1148 |  |             { | 
|  | 0 | 1149 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix"); | 
|  |  | 1150 |  |             } | 
|  | 30 | 1151 |  |             if (Client.IndexName == null) | 
|  |  | 1152 |  |             { | 
|  | 0 | 1153 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.IndexName"); | 
|  |  | 1154 |  |             } | 
|  | 30 | 1155 |  |             if (searchText == null) | 
|  |  | 1156 |  |             { | 
|  | 0 | 1157 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "searchText"); | 
|  |  | 1158 |  |             } | 
|  | 30 | 1159 |  |             if (suggesterName == null) | 
|  |  | 1160 |  |             { | 
|  | 0 | 1161 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "suggesterName"); | 
|  |  | 1162 |  |             } | 
|  | 30 | 1163 |  |             if (Client.ApiVersion == null) | 
|  |  | 1164 |  |             { | 
|  | 0 | 1165 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); | 
|  |  | 1166 |  |             } | 
|  | 30 | 1167 |  |             string filter = default(string); | 
|  | 30 | 1168 |  |             if (suggestParameters != null) | 
|  |  | 1169 |  |             { | 
|  | 30 | 1170 |  |                 filter = suggestParameters.Filter; | 
|  |  | 1171 |  |             } | 
|  | 30 | 1172 |  |             bool useFuzzyMatching = default(bool); | 
|  | 30 | 1173 |  |             if (suggestParameters != null) | 
|  |  | 1174 |  |             { | 
|  | 30 | 1175 |  |                 useFuzzyMatching = suggestParameters.UseFuzzyMatching; | 
|  |  | 1176 |  |             } | 
|  | 30 | 1177 |  |             string highlightPostTag = default(string); | 
|  | 30 | 1178 |  |             if (suggestParameters != null) | 
|  |  | 1179 |  |             { | 
|  | 30 | 1180 |  |                 highlightPostTag = suggestParameters.HighlightPostTag; | 
|  |  | 1181 |  |             } | 
|  | 30 | 1182 |  |             string highlightPreTag = default(string); | 
|  | 30 | 1183 |  |             if (suggestParameters != null) | 
|  |  | 1184 |  |             { | 
|  | 30 | 1185 |  |                 highlightPreTag = suggestParameters.HighlightPreTag; | 
|  |  | 1186 |  |             } | 
|  | 30 | 1187 |  |             double? minimumCoverage = default(double?); | 
|  | 30 | 1188 |  |             if (suggestParameters != null) | 
|  |  | 1189 |  |             { | 
|  | 30 | 1190 |  |                 minimumCoverage = suggestParameters.MinimumCoverage; | 
|  |  | 1191 |  |             } | 
|  | 30 | 1192 |  |             IList<string> orderBy = default(IList<string>); | 
|  | 30 | 1193 |  |             if (suggestParameters != null) | 
|  |  | 1194 |  |             { | 
|  | 30 | 1195 |  |                 orderBy = suggestParameters.OrderBy; | 
|  |  | 1196 |  |             } | 
|  | 30 | 1197 |  |             IList<string> searchFields = default(IList<string>); | 
|  | 30 | 1198 |  |             if (suggestParameters != null) | 
|  |  | 1199 |  |             { | 
|  | 30 | 1200 |  |                 searchFields = suggestParameters.SearchFields; | 
|  |  | 1201 |  |             } | 
|  | 30 | 1202 |  |             IList<string> select = default(IList<string>); | 
|  | 30 | 1203 |  |             if (suggestParameters != null) | 
|  |  | 1204 |  |             { | 
|  | 30 | 1205 |  |                 select = suggestParameters.Select; | 
|  |  | 1206 |  |             } | 
|  | 30 | 1207 |  |             int? top = default(int?); | 
|  | 30 | 1208 |  |             if (suggestParameters != null) | 
|  |  | 1209 |  |             { | 
|  | 30 | 1210 |  |                 top = suggestParameters.Top; | 
|  |  | 1211 |  |             } | 
|  | 30 | 1212 |  |             System.Guid? clientRequestId = default(System.Guid?); | 
|  | 30 | 1213 |  |             if (searchRequestOptions != null) | 
|  |  | 1214 |  |             { | 
|  | 0 | 1215 |  |                 clientRequestId = searchRequestOptions.ClientRequestId; | 
|  |  | 1216 |  |             } | 
|  |  | 1217 |  |             // Tracing | 
|  | 30 | 1218 |  |             bool _shouldTrace = ServiceClientTracing.IsEnabled; | 
|  | 30 | 1219 |  |             string _invocationId = null; | 
|  | 30 | 1220 |  |             if (_shouldTrace) | 
|  |  | 1221 |  |             { | 
|  | 0 | 1222 |  |                 _invocationId = ServiceClientTracing.NextInvocationId.ToString(); | 
|  | 0 | 1223 |  |                 Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); | 
|  | 0 | 1224 |  |                 tracingParameters.Add("searchText", searchText); | 
|  | 0 | 1225 |  |                 tracingParameters.Add("suggesterName", suggesterName); | 
|  | 0 | 1226 |  |                 tracingParameters.Add("filter", filter); | 
|  | 0 | 1227 |  |                 tracingParameters.Add("useFuzzyMatching", useFuzzyMatching); | 
|  | 0 | 1228 |  |                 tracingParameters.Add("highlightPostTag", highlightPostTag); | 
|  | 0 | 1229 |  |                 tracingParameters.Add("highlightPreTag", highlightPreTag); | 
|  | 0 | 1230 |  |                 tracingParameters.Add("minimumCoverage", minimumCoverage); | 
|  | 0 | 1231 |  |                 tracingParameters.Add("orderBy", orderBy); | 
|  | 0 | 1232 |  |                 tracingParameters.Add("searchFields", searchFields); | 
|  | 0 | 1233 |  |                 tracingParameters.Add("select", select); | 
|  | 0 | 1234 |  |                 tracingParameters.Add("top", top); | 
|  | 0 | 1235 |  |                 tracingParameters.Add("clientRequestId", clientRequestId); | 
|  | 0 | 1236 |  |                 tracingParameters.Add("cancellationToken", cancellationToken); | 
|  | 0 | 1237 |  |                 ServiceClientTracing.Enter(_invocationId, this, "SuggestGet", tracingParameters); | 
|  |  | 1238 |  |             } | 
|  |  | 1239 |  |             // Construct URL | 
|  | 30 | 1240 |  |             var _baseUrl = Client.BaseUri; | 
|  | 30 | 1241 |  |             var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "docs/search.suggest"; | 
|  | 30 | 1242 |  |             _url = _url.Replace("{searchServiceName}", Client.SearchServiceName); | 
|  | 30 | 1243 |  |             _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix); | 
|  | 30 | 1244 |  |             _url = _url.Replace("{indexName}", Client.IndexName); | 
|  | 30 | 1245 |  |             List<string> _queryParameters = new List<string>(); | 
|  | 30 | 1246 |  |             if (searchText != null) | 
|  |  | 1247 |  |             { | 
|  | 30 | 1248 |  |                 _queryParameters.Add(string.Format("search={0}", System.Uri.EscapeDataString(searchText))); | 
|  |  | 1249 |  |             } | 
|  | 30 | 1250 |  |             if (suggesterName != null) | 
|  |  | 1251 |  |             { | 
|  | 30 | 1252 |  |                 _queryParameters.Add(string.Format("suggesterName={0}", System.Uri.EscapeDataString(suggesterName))); | 
|  |  | 1253 |  |             } | 
|  | 30 | 1254 |  |             if (Client.ApiVersion != null) | 
|  |  | 1255 |  |             { | 
|  | 30 | 1256 |  |                 _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); | 
|  |  | 1257 |  |             } | 
|  | 30 | 1258 |  |             if (filter != null) | 
|  |  | 1259 |  |             { | 
|  | 4 | 1260 |  |                 _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); | 
|  |  | 1261 |  |             } | 
|  | 30 | 1262 |  |             _queryParameters.Add(string.Format("fuzzy={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConve | 
|  | 30 | 1263 |  |             if (highlightPostTag != null) | 
|  |  | 1264 |  |             { | 
|  | 2 | 1265 |  |                 _queryParameters.Add(string.Format("highlightPostTag={0}", System.Uri.EscapeDataString(highlightPostTag) | 
|  |  | 1266 |  |             } | 
|  | 30 | 1267 |  |             if (highlightPreTag != null) | 
|  |  | 1268 |  |             { | 
|  | 2 | 1269 |  |                 _queryParameters.Add(string.Format("highlightPreTag={0}", System.Uri.EscapeDataString(highlightPreTag))) | 
|  |  | 1270 |  |             } | 
|  | 30 | 1271 |  |             if (minimumCoverage != null) | 
|  |  | 1272 |  |             { | 
|  | 2 | 1273 |  |                 _queryParameters.Add(string.Format("minimumCoverage={0}", System.Uri.EscapeDataString(Rest.Serialization | 
|  |  | 1274 |  |             } | 
|  | 30 | 1275 |  |             if (orderBy != null) | 
|  |  | 1276 |  |             { | 
|  | 12 | 1277 |  |                 _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(string.Join(",", orderBy) | 
|  |  | 1278 |  |             } | 
|  | 30 | 1279 |  |             if (searchFields != null) | 
|  |  | 1280 |  |             { | 
|  | 2 | 1281 |  |                 _queryParameters.Add(string.Format("searchFields={0}", System.Uri.EscapeDataString(string.Join(",", sear | 
|  |  | 1282 |  |             } | 
|  | 30 | 1283 |  |             if (select != null) | 
|  |  | 1284 |  |             { | 
|  | 30 | 1285 |  |                 _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(string.Join(",", select))) | 
|  |  | 1286 |  |             } | 
|  | 30 | 1287 |  |             if (top != null) | 
|  |  | 1288 |  |             { | 
|  | 4 | 1289 |  |                 _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo | 
|  |  | 1290 |  |             } | 
|  | 30 | 1291 |  |             if (_queryParameters.Count > 0) | 
|  |  | 1292 |  |             { | 
|  | 30 | 1293 |  |                 _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); | 
|  |  | 1294 |  |             } | 
|  |  | 1295 |  |             // Create HTTP transport objects | 
|  | 30 | 1296 |  |             var _httpRequest = new HttpRequestMessage(); | 
|  | 30 | 1297 |  |             HttpResponseMessage _httpResponse = null; | 
|  | 30 | 1298 |  |             _httpRequest.Method = new HttpMethod("GET"); | 
|  | 30 | 1299 |  |             _httpRequest.RequestUri = new System.Uri(_url); | 
|  |  | 1300 |  |             // Set Headers | 
|  | 30 | 1301 |  |             if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) | 
|  |  | 1302 |  |             { | 
|  | 30 | 1303 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); | 
|  |  | 1304 |  |             } | 
|  | 30 | 1305 |  |             if (Client.AcceptLanguage != null) | 
|  |  | 1306 |  |             { | 
|  | 30 | 1307 |  |                 if (_httpRequest.Headers.Contains("accept-language")) | 
|  |  | 1308 |  |                 { | 
|  | 0 | 1309 |  |                     _httpRequest.Headers.Remove("accept-language"); | 
|  |  | 1310 |  |                 } | 
|  | 30 | 1311 |  |                 _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); | 
|  |  | 1312 |  |             } | 
|  | 30 | 1313 |  |             if (clientRequestId != null) | 
|  |  | 1314 |  |             { | 
|  | 0 | 1315 |  |                 if (_httpRequest.Headers.Contains("client-request-id")) | 
|  |  | 1316 |  |                 { | 
|  | 0 | 1317 |  |                     _httpRequest.Headers.Remove("client-request-id"); | 
|  |  | 1318 |  |                 } | 
|  | 0 | 1319 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser | 
|  |  | 1320 |  |             } | 
|  |  | 1321 |  |  | 
|  |  | 1322 |  |  | 
|  | 30 | 1323 |  |             if (customHeaders != null) | 
|  |  | 1324 |  |             { | 
|  | 120 | 1325 |  |                 foreach(var _header in customHeaders) | 
|  |  | 1326 |  |                 { | 
|  | 30 | 1327 |  |                     if (_httpRequest.Headers.Contains(_header.Key)) | 
|  |  | 1328 |  |                     { | 
|  | 0 | 1329 |  |                         _httpRequest.Headers.Remove(_header.Key); | 
|  |  | 1330 |  |                     } | 
|  | 30 | 1331 |  |                     _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); | 
|  |  | 1332 |  |                 } | 
|  |  | 1333 |  |             } | 
|  |  | 1334 |  |  | 
|  |  | 1335 |  |             // Serialize Request | 
|  | 30 | 1336 |  |             string _requestContent = null; | 
|  |  | 1337 |  |             // Set Credentials | 
|  | 30 | 1338 |  |             if (Client.Credentials != null) | 
|  |  | 1339 |  |             { | 
|  | 30 | 1340 |  |                 cancellationToken.ThrowIfCancellationRequested(); | 
|  | 30 | 1341 |  |                 await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  |  | 1342 |  |             } | 
|  |  | 1343 |  |             // Send Request | 
|  | 30 | 1344 |  |             if (_shouldTrace) | 
|  |  | 1345 |  |             { | 
|  | 0 | 1346 |  |                 ServiceClientTracing.SendRequest(_invocationId, _httpRequest); | 
|  |  | 1347 |  |             } | 
|  | 30 | 1348 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 30 | 1349 |  |             _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  | 30 | 1350 |  |             if (_shouldTrace) | 
|  |  | 1351 |  |             { | 
|  | 0 | 1352 |  |                 ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); | 
|  |  | 1353 |  |             } | 
|  | 30 | 1354 |  |             HttpStatusCode _statusCode = _httpResponse.StatusCode; | 
|  | 30 | 1355 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 30 | 1356 |  |             string _responseContent = null; | 
|  | 30 | 1357 |  |             if ((int)_statusCode != 200) | 
|  |  | 1358 |  |             { | 
|  | 4 | 1359 |  |                 var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode | 
|  |  | 1360 |  |                 try | 
|  |  | 1361 |  |                 { | 
|  | 4 | 1362 |  |                     _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  | 4 | 1363 |  |                     CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC | 
|  | 4 | 1364 |  |                     if (_errorBody != null) | 
|  |  | 1365 |  |                     { | 
|  | 4 | 1366 |  |                         ex = new CloudException(_errorBody.Message); | 
|  | 4 | 1367 |  |                         ex.Body = _errorBody; | 
|  |  | 1368 |  |                     } | 
|  | 4 | 1369 |  |                 } | 
|  | 0 | 1370 |  |                 catch (JsonException) | 
|  |  | 1371 |  |                 { | 
|  |  | 1372 |  |                     // Ignore the exception | 
|  | 0 | 1373 |  |                 } | 
|  | 4 | 1374 |  |                 ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); | 
|  | 4 | 1375 |  |                 ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); | 
|  | 4 | 1376 |  |                 if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 1377 |  |                 { | 
|  | 4 | 1378 |  |                     ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 1379 |  |                 } | 
|  | 4 | 1380 |  |                 if (_shouldTrace) | 
|  |  | 1381 |  |                 { | 
|  | 0 | 1382 |  |                     ServiceClientTracing.Error(_invocationId, ex); | 
|  |  | 1383 |  |                 } | 
|  | 4 | 1384 |  |                 _httpRequest.Dispose(); | 
|  | 4 | 1385 |  |                 if (_httpResponse != null) | 
|  |  | 1386 |  |                 { | 
|  | 4 | 1387 |  |                     _httpResponse.Dispose(); | 
|  |  | 1388 |  |                 } | 
|  | 4 | 1389 |  |                 throw ex; | 
|  |  | 1390 |  |             } | 
|  |  | 1391 |  |             // Create Result | 
|  | 26 | 1392 |  |             var _result = new AzureOperationResponse<DocumentSuggestResult<T>>(); | 
|  | 26 | 1393 |  |             _result.Request = _httpRequest; | 
|  | 26 | 1394 |  |             _result.Response = _httpResponse; | 
|  | 26 | 1395 |  |             if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 1396 |  |             { | 
|  | 26 | 1397 |  |                 _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 1398 |  |             } | 
|  |  | 1399 |  |             // Deserialize Response | 
|  | 26 | 1400 |  |             if ((int)_statusCode == 200) | 
|  |  | 1401 |  |             { | 
|  | 26 | 1402 |  |                 _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  |  | 1403 |  |                 try | 
|  |  | 1404 |  |                 { | 
|  | 26 | 1405 |  |                     _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<DocumentSuggestResult<T>>(_respo | 
|  | 26 | 1406 |  |                 } | 
|  | 0 | 1407 |  |                 catch (JsonException ex) | 
|  |  | 1408 |  |                 { | 
|  | 0 | 1409 |  |                     _httpRequest.Dispose(); | 
|  | 0 | 1410 |  |                     if (_httpResponse != null) | 
|  |  | 1411 |  |                     { | 
|  | 0 | 1412 |  |                         _httpResponse.Dispose(); | 
|  |  | 1413 |  |                     } | 
|  | 0 | 1414 |  |                     throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); | 
|  |  | 1415 |  |                 } | 
|  |  | 1416 |  |             } | 
|  | 26 | 1417 |  |             if (_shouldTrace) | 
|  |  | 1418 |  |             { | 
|  | 0 | 1419 |  |                 ServiceClientTracing.Exit(_invocationId, _result); | 
|  |  | 1420 |  |             } | 
|  | 26 | 1421 |  |             return _result; | 
|  | 26 | 1422 |  |         } | 
|  |  | 1423 |  |  | 
|  |  | 1424 |  |         /// <summary> | 
|  |  | 1425 |  |         /// Suggests documents in the index that match the given partial query text. | 
|  |  | 1426 |  |         /// <see href="https://docs.microsoft.com/rest/api/searchservice/suggestions" /> | 
|  |  | 1427 |  |         /// </summary> | 
|  |  | 1428 |  |         /// <param name='suggestRequest'> | 
|  |  | 1429 |  |         /// The Suggest request. | 
|  |  | 1430 |  |         /// </param> | 
|  |  | 1431 |  |         /// <param name='searchRequestOptions'> | 
|  |  | 1432 |  |         /// Additional parameters for the operation | 
|  |  | 1433 |  |         /// </param> | 
|  |  | 1434 |  |         /// <param name='customHeaders'> | 
|  |  | 1435 |  |         /// Headers that will be added to request. | 
|  |  | 1436 |  |         /// </param> | 
|  |  | 1437 |  |         /// <param name='cancellationToken'> | 
|  |  | 1438 |  |         /// The cancellation token. | 
|  |  | 1439 |  |         /// </param> | 
|  |  | 1440 |  |         /// <exception cref="CloudException"> | 
|  |  | 1441 |  |         /// Thrown when the operation returned an invalid status code | 
|  |  | 1442 |  |         /// </exception> | 
|  |  | 1443 |  |         /// <exception cref="SerializationException"> | 
|  |  | 1444 |  |         /// Thrown when unable to deserialize the response | 
|  |  | 1445 |  |         /// </exception> | 
|  |  | 1446 |  |         /// <exception cref="ValidationException"> | 
|  |  | 1447 |  |         /// Thrown when a required parameter is null | 
|  |  | 1448 |  |         /// </exception> | 
|  |  | 1449 |  |         /// <exception cref="System.ArgumentNullException"> | 
|  |  | 1450 |  |         /// Thrown when a required parameter is null | 
|  |  | 1451 |  |         /// </exception> | 
|  |  | 1452 |  |         /// <return> | 
|  |  | 1453 |  |         /// A response object containing the response body and response headers. | 
|  |  | 1454 |  |         /// </return> | 
|  |  | 1455 |  |         public async Task<AzureOperationResponse<DocumentSuggestResult<T>>> SuggestPostWithHttpMessagesAsync<T>(SuggestR | 
|  |  | 1456 |  |         { | 
|  | 42 | 1457 |  |             if (Client.SearchServiceName == null) | 
|  |  | 1458 |  |             { | 
|  | 0 | 1459 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName"); | 
|  |  | 1460 |  |             } | 
|  | 42 | 1461 |  |             if (Client.SearchDnsSuffix == null) | 
|  |  | 1462 |  |             { | 
|  | 0 | 1463 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix"); | 
|  |  | 1464 |  |             } | 
|  | 42 | 1465 |  |             if (Client.IndexName == null) | 
|  |  | 1466 |  |             { | 
|  | 0 | 1467 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.IndexName"); | 
|  |  | 1468 |  |             } | 
|  | 42 | 1469 |  |             if (suggestRequest == null) | 
|  |  | 1470 |  |             { | 
|  | 0 | 1471 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "suggestRequest"); | 
|  |  | 1472 |  |             } | 
|  | 42 | 1473 |  |             if (Client.ApiVersion == null) | 
|  |  | 1474 |  |             { | 
|  | 0 | 1475 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); | 
|  |  | 1476 |  |             } | 
|  | 42 | 1477 |  |             System.Guid? clientRequestId = default(System.Guid?); | 
|  | 42 | 1478 |  |             if (searchRequestOptions != null) | 
|  |  | 1479 |  |             { | 
|  | 0 | 1480 |  |                 clientRequestId = searchRequestOptions.ClientRequestId; | 
|  |  | 1481 |  |             } | 
|  |  | 1482 |  |             // Tracing | 
|  | 42 | 1483 |  |             bool _shouldTrace = ServiceClientTracing.IsEnabled; | 
|  | 42 | 1484 |  |             string _invocationId = null; | 
|  | 42 | 1485 |  |             if (_shouldTrace) | 
|  |  | 1486 |  |             { | 
|  | 0 | 1487 |  |                 _invocationId = ServiceClientTracing.NextInvocationId.ToString(); | 
|  | 0 | 1488 |  |                 Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); | 
|  | 0 | 1489 |  |                 tracingParameters.Add("suggestRequest", suggestRequest); | 
|  | 0 | 1490 |  |                 tracingParameters.Add("clientRequestId", clientRequestId); | 
|  | 0 | 1491 |  |                 tracingParameters.Add("cancellationToken", cancellationToken); | 
|  | 0 | 1492 |  |                 ServiceClientTracing.Enter(_invocationId, this, "SuggestPost", tracingParameters); | 
|  |  | 1493 |  |             } | 
|  |  | 1494 |  |             // Construct URL | 
|  | 42 | 1495 |  |             var _baseUrl = Client.BaseUri; | 
|  | 42 | 1496 |  |             var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "docs/search.post.suggest"; | 
|  | 42 | 1497 |  |             _url = _url.Replace("{searchServiceName}", Client.SearchServiceName); | 
|  | 42 | 1498 |  |             _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix); | 
|  | 42 | 1499 |  |             _url = _url.Replace("{indexName}", Client.IndexName); | 
|  | 42 | 1500 |  |             List<string> _queryParameters = new List<string>(); | 
|  | 42 | 1501 |  |             if (Client.ApiVersion != null) | 
|  |  | 1502 |  |             { | 
|  | 42 | 1503 |  |                 _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); | 
|  |  | 1504 |  |             } | 
|  | 42 | 1505 |  |             if (_queryParameters.Count > 0) | 
|  |  | 1506 |  |             { | 
|  | 42 | 1507 |  |                 _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); | 
|  |  | 1508 |  |             } | 
|  |  | 1509 |  |             // Create HTTP transport objects | 
|  | 42 | 1510 |  |             var _httpRequest = new HttpRequestMessage(); | 
|  | 42 | 1511 |  |             HttpResponseMessage _httpResponse = null; | 
|  | 42 | 1512 |  |             _httpRequest.Method = new HttpMethod("POST"); | 
|  | 42 | 1513 |  |             _httpRequest.RequestUri = new System.Uri(_url); | 
|  |  | 1514 |  |             // Set Headers | 
|  | 42 | 1515 |  |             if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) | 
|  |  | 1516 |  |             { | 
|  | 42 | 1517 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); | 
|  |  | 1518 |  |             } | 
|  | 42 | 1519 |  |             if (Client.AcceptLanguage != null) | 
|  |  | 1520 |  |             { | 
|  | 42 | 1521 |  |                 if (_httpRequest.Headers.Contains("accept-language")) | 
|  |  | 1522 |  |                 { | 
|  | 0 | 1523 |  |                     _httpRequest.Headers.Remove("accept-language"); | 
|  |  | 1524 |  |                 } | 
|  | 42 | 1525 |  |                 _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); | 
|  |  | 1526 |  |             } | 
|  | 42 | 1527 |  |             if (clientRequestId != null) | 
|  |  | 1528 |  |             { | 
|  | 0 | 1529 |  |                 if (_httpRequest.Headers.Contains("client-request-id")) | 
|  |  | 1530 |  |                 { | 
|  | 0 | 1531 |  |                     _httpRequest.Headers.Remove("client-request-id"); | 
|  |  | 1532 |  |                 } | 
|  | 0 | 1533 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser | 
|  |  | 1534 |  |             } | 
|  |  | 1535 |  |  | 
|  |  | 1536 |  |  | 
|  | 42 | 1537 |  |             if (customHeaders != null) | 
|  |  | 1538 |  |             { | 
|  | 168 | 1539 |  |                 foreach(var _header in customHeaders) | 
|  |  | 1540 |  |                 { | 
|  | 42 | 1541 |  |                     if (_httpRequest.Headers.Contains(_header.Key)) | 
|  |  | 1542 |  |                     { | 
|  | 0 | 1543 |  |                         _httpRequest.Headers.Remove(_header.Key); | 
|  |  | 1544 |  |                     } | 
|  | 42 | 1545 |  |                     _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); | 
|  |  | 1546 |  |                 } | 
|  |  | 1547 |  |             } | 
|  |  | 1548 |  |  | 
|  |  | 1549 |  |             // Serialize Request | 
|  | 42 | 1550 |  |             string _requestContent = null; | 
|  | 42 | 1551 |  |             if(suggestRequest != null) | 
|  |  | 1552 |  |             { | 
|  | 42 | 1553 |  |                 _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(suggestRequest, requestSerializerSe | 
|  | 42 | 1554 |  |                 _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); | 
|  | 42 | 1555 |  |                 _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio | 
|  |  | 1556 |  |             } | 
|  |  | 1557 |  |             // Set Credentials | 
|  | 42 | 1558 |  |             if (Client.Credentials != null) | 
|  |  | 1559 |  |             { | 
|  | 42 | 1560 |  |                 cancellationToken.ThrowIfCancellationRequested(); | 
|  | 42 | 1561 |  |                 await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  |  | 1562 |  |             } | 
|  |  | 1563 |  |             // Send Request | 
|  | 42 | 1564 |  |             if (_shouldTrace) | 
|  |  | 1565 |  |             { | 
|  | 0 | 1566 |  |                 ServiceClientTracing.SendRequest(_invocationId, _httpRequest); | 
|  |  | 1567 |  |             } | 
|  | 42 | 1568 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 42 | 1569 |  |             _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  | 42 | 1570 |  |             if (_shouldTrace) | 
|  |  | 1571 |  |             { | 
|  | 0 | 1572 |  |                 ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); | 
|  |  | 1573 |  |             } | 
|  | 42 | 1574 |  |             HttpStatusCode _statusCode = _httpResponse.StatusCode; | 
|  | 42 | 1575 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 42 | 1576 |  |             string _responseContent = null; | 
|  | 42 | 1577 |  |             if ((int)_statusCode != 200) | 
|  |  | 1578 |  |             { | 
|  | 4 | 1579 |  |                 var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode | 
|  |  | 1580 |  |                 try | 
|  |  | 1581 |  |                 { | 
|  | 4 | 1582 |  |                     _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  | 4 | 1583 |  |                     CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC | 
|  | 4 | 1584 |  |                     if (_errorBody != null) | 
|  |  | 1585 |  |                     { | 
|  | 4 | 1586 |  |                         ex = new CloudException(_errorBody.Message); | 
|  | 4 | 1587 |  |                         ex.Body = _errorBody; | 
|  |  | 1588 |  |                     } | 
|  | 4 | 1589 |  |                 } | 
|  | 0 | 1590 |  |                 catch (JsonException) | 
|  |  | 1591 |  |                 { | 
|  |  | 1592 |  |                     // Ignore the exception | 
|  | 0 | 1593 |  |                 } | 
|  | 4 | 1594 |  |                 ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); | 
|  | 4 | 1595 |  |                 ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); | 
|  | 4 | 1596 |  |                 if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 1597 |  |                 { | 
|  | 4 | 1598 |  |                     ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 1599 |  |                 } | 
|  | 4 | 1600 |  |                 if (_shouldTrace) | 
|  |  | 1601 |  |                 { | 
|  | 0 | 1602 |  |                     ServiceClientTracing.Error(_invocationId, ex); | 
|  |  | 1603 |  |                 } | 
|  | 4 | 1604 |  |                 _httpRequest.Dispose(); | 
|  | 4 | 1605 |  |                 if (_httpResponse != null) | 
|  |  | 1606 |  |                 { | 
|  | 4 | 1607 |  |                     _httpResponse.Dispose(); | 
|  |  | 1608 |  |                 } | 
|  | 4 | 1609 |  |                 throw ex; | 
|  |  | 1610 |  |             } | 
|  |  | 1611 |  |             // Create Result | 
|  | 38 | 1612 |  |             var _result = new AzureOperationResponse<DocumentSuggestResult<T>>(); | 
|  | 38 | 1613 |  |             _result.Request = _httpRequest; | 
|  | 38 | 1614 |  |             _result.Response = _httpResponse; | 
|  | 38 | 1615 |  |             if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 1616 |  |             { | 
|  | 38 | 1617 |  |                 _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 1618 |  |             } | 
|  |  | 1619 |  |             // Deserialize Response | 
|  | 38 | 1620 |  |             if ((int)_statusCode == 200) | 
|  |  | 1621 |  |             { | 
|  | 38 | 1622 |  |                 _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  |  | 1623 |  |                 try | 
|  |  | 1624 |  |                 { | 
|  | 38 | 1625 |  |                     _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<DocumentSuggestResult<T>>(_respo | 
|  | 38 | 1626 |  |                 } | 
|  | 0 | 1627 |  |                 catch (JsonException ex) | 
|  |  | 1628 |  |                 { | 
|  | 0 | 1629 |  |                     _httpRequest.Dispose(); | 
|  | 0 | 1630 |  |                     if (_httpResponse != null) | 
|  |  | 1631 |  |                     { | 
|  | 0 | 1632 |  |                         _httpResponse.Dispose(); | 
|  |  | 1633 |  |                     } | 
|  | 0 | 1634 |  |                     throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); | 
|  |  | 1635 |  |                 } | 
|  |  | 1636 |  |             } | 
|  | 38 | 1637 |  |             if (_shouldTrace) | 
|  |  | 1638 |  |             { | 
|  | 0 | 1639 |  |                 ServiceClientTracing.Exit(_invocationId, _result); | 
|  |  | 1640 |  |             } | 
|  | 38 | 1641 |  |             return _result; | 
|  | 38 | 1642 |  |         } | 
|  |  | 1643 |  |  | 
|  |  | 1644 |  |         /// <summary> | 
|  |  | 1645 |  |         /// Sends a batch of document write actions to the index. | 
|  |  | 1646 |  |         /// <see href="https://docs.microsoft.com/rest/api/searchservice/addupdate-or-delete-documents" /> | 
|  |  | 1647 |  |         /// </summary> | 
|  |  | 1648 |  |         /// <param name='batch'> | 
|  |  | 1649 |  |         /// The batch of index actions. | 
|  |  | 1650 |  |         /// </param> | 
|  |  | 1651 |  |         /// <param name='searchRequestOptions'> | 
|  |  | 1652 |  |         /// Additional parameters for the operation | 
|  |  | 1653 |  |         /// </param> | 
|  |  | 1654 |  |         /// <param name='customHeaders'> | 
|  |  | 1655 |  |         /// Headers that will be added to request. | 
|  |  | 1656 |  |         /// </param> | 
|  |  | 1657 |  |         /// <param name='cancellationToken'> | 
|  |  | 1658 |  |         /// The cancellation token. | 
|  |  | 1659 |  |         /// </param> | 
|  |  | 1660 |  |         /// <exception cref="CloudException"> | 
|  |  | 1661 |  |         /// Thrown when the operation returned an invalid status code | 
|  |  | 1662 |  |         /// </exception> | 
|  |  | 1663 |  |         /// <exception cref="SerializationException"> | 
|  |  | 1664 |  |         /// Thrown when unable to deserialize the response | 
|  |  | 1665 |  |         /// </exception> | 
|  |  | 1666 |  |         /// <exception cref="ValidationException"> | 
|  |  | 1667 |  |         /// Thrown when a required parameter is null | 
|  |  | 1668 |  |         /// </exception> | 
|  |  | 1669 |  |         /// <exception cref="System.ArgumentNullException"> | 
|  |  | 1670 |  |         /// Thrown when a required parameter is null | 
|  |  | 1671 |  |         /// </exception> | 
|  |  | 1672 |  |         /// <return> | 
|  |  | 1673 |  |         /// A response object containing the response body and response headers. | 
|  |  | 1674 |  |         /// </return> | 
|  |  | 1675 |  |         public async Task<AzureOperationResponse<DocumentIndexResult>> IndexWithHttpMessagesAsync<T>(IndexBatch<T> batch | 
|  |  | 1676 |  |         { | 
|  | 446 | 1677 |  |             if (Client.SearchServiceName == null) | 
|  |  | 1678 |  |             { | 
|  | 0 | 1679 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName"); | 
|  |  | 1680 |  |             } | 
|  | 446 | 1681 |  |             if (Client.SearchDnsSuffix == null) | 
|  |  | 1682 |  |             { | 
|  | 0 | 1683 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix"); | 
|  |  | 1684 |  |             } | 
|  | 446 | 1685 |  |             if (Client.IndexName == null) | 
|  |  | 1686 |  |             { | 
|  | 0 | 1687 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.IndexName"); | 
|  |  | 1688 |  |             } | 
|  | 446 | 1689 |  |             if (batch == null) | 
|  |  | 1690 |  |             { | 
|  | 0 | 1691 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "batch"); | 
|  |  | 1692 |  |             } | 
|  | 446 | 1693 |  |             if (batch != null) | 
|  |  | 1694 |  |             { | 
|  | 446 | 1695 |  |                 batch.Validate(); | 
|  |  | 1696 |  |             } | 
|  | 446 | 1697 |  |             if (Client.ApiVersion == null) | 
|  |  | 1698 |  |             { | 
|  | 0 | 1699 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); | 
|  |  | 1700 |  |             } | 
|  | 446 | 1701 |  |             System.Guid? clientRequestId = default(System.Guid?); | 
|  | 446 | 1702 |  |             if (searchRequestOptions != null) | 
|  |  | 1703 |  |             { | 
|  | 0 | 1704 |  |                 clientRequestId = searchRequestOptions.ClientRequestId; | 
|  |  | 1705 |  |             } | 
|  |  | 1706 |  |             // Tracing | 
|  | 446 | 1707 |  |             bool _shouldTrace = ServiceClientTracing.IsEnabled; | 
|  | 446 | 1708 |  |             string _invocationId = null; | 
|  | 446 | 1709 |  |             if (_shouldTrace) | 
|  |  | 1710 |  |             { | 
|  | 0 | 1711 |  |                 _invocationId = ServiceClientTracing.NextInvocationId.ToString(); | 
|  | 0 | 1712 |  |                 Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); | 
|  | 0 | 1713 |  |                 tracingParameters.Add("batch", batch); | 
|  | 0 | 1714 |  |                 tracingParameters.Add("clientRequestId", clientRequestId); | 
|  | 0 | 1715 |  |                 tracingParameters.Add("cancellationToken", cancellationToken); | 
|  | 0 | 1716 |  |                 ServiceClientTracing.Enter(_invocationId, this, "Index", tracingParameters); | 
|  |  | 1717 |  |             } | 
|  |  | 1718 |  |             // Construct URL | 
|  | 446 | 1719 |  |             var _baseUrl = Client.BaseUri; | 
|  | 446 | 1720 |  |             var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "docs/search.index"; | 
|  | 446 | 1721 |  |             _url = _url.Replace("{searchServiceName}", Client.SearchServiceName); | 
|  | 446 | 1722 |  |             _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix); | 
|  | 446 | 1723 |  |             _url = _url.Replace("{indexName}", Client.IndexName); | 
|  | 446 | 1724 |  |             List<string> _queryParameters = new List<string>(); | 
|  | 446 | 1725 |  |             if (Client.ApiVersion != null) | 
|  |  | 1726 |  |             { | 
|  | 446 | 1727 |  |                 _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); | 
|  |  | 1728 |  |             } | 
|  | 446 | 1729 |  |             if (_queryParameters.Count > 0) | 
|  |  | 1730 |  |             { | 
|  | 446 | 1731 |  |                 _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); | 
|  |  | 1732 |  |             } | 
|  |  | 1733 |  |             // Create HTTP transport objects | 
|  | 446 | 1734 |  |             var _httpRequest = new HttpRequestMessage(); | 
|  | 446 | 1735 |  |             HttpResponseMessage _httpResponse = null; | 
|  | 446 | 1736 |  |             _httpRequest.Method = new HttpMethod("POST"); | 
|  | 446 | 1737 |  |             _httpRequest.RequestUri = new System.Uri(_url); | 
|  |  | 1738 |  |             // Set Headers | 
|  | 446 | 1739 |  |             if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) | 
|  |  | 1740 |  |             { | 
|  | 446 | 1741 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); | 
|  |  | 1742 |  |             } | 
|  | 446 | 1743 |  |             if (Client.AcceptLanguage != null) | 
|  |  | 1744 |  |             { | 
|  | 446 | 1745 |  |                 if (_httpRequest.Headers.Contains("accept-language")) | 
|  |  | 1746 |  |                 { | 
|  | 0 | 1747 |  |                     _httpRequest.Headers.Remove("accept-language"); | 
|  |  | 1748 |  |                 } | 
|  | 446 | 1749 |  |                 _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); | 
|  |  | 1750 |  |             } | 
|  | 446 | 1751 |  |             if (clientRequestId != null) | 
|  |  | 1752 |  |             { | 
|  | 0 | 1753 |  |                 if (_httpRequest.Headers.Contains("client-request-id")) | 
|  |  | 1754 |  |                 { | 
|  | 0 | 1755 |  |                     _httpRequest.Headers.Remove("client-request-id"); | 
|  |  | 1756 |  |                 } | 
|  | 0 | 1757 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser | 
|  |  | 1758 |  |             } | 
|  |  | 1759 |  |  | 
|  |  | 1760 |  |  | 
|  | 446 | 1761 |  |             if (customHeaders != null) | 
|  |  | 1762 |  |             { | 
|  | 1784 | 1763 |  |                 foreach(var _header in customHeaders) | 
|  |  | 1764 |  |                 { | 
|  | 446 | 1765 |  |                     if (_httpRequest.Headers.Contains(_header.Key)) | 
|  |  | 1766 |  |                     { | 
|  | 0 | 1767 |  |                         _httpRequest.Headers.Remove(_header.Key); | 
|  |  | 1768 |  |                     } | 
|  | 446 | 1769 |  |                     _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); | 
|  |  | 1770 |  |                 } | 
|  |  | 1771 |  |             } | 
|  |  | 1772 |  |  | 
|  |  | 1773 |  |             // Serialize Request | 
|  | 446 | 1774 |  |             string _requestContent = null; | 
|  | 446 | 1775 |  |             if(batch != null) | 
|  |  | 1776 |  |             { | 
|  | 446 | 1777 |  |                 _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(batch, requestSerializerSettings ?? | 
|  | 446 | 1778 |  |                 _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); | 
|  | 446 | 1779 |  |                 _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio | 
|  |  | 1780 |  |             } | 
|  |  | 1781 |  |             // Set Credentials | 
|  | 446 | 1782 |  |             if (Client.Credentials != null) | 
|  |  | 1783 |  |             { | 
|  | 446 | 1784 |  |                 cancellationToken.ThrowIfCancellationRequested(); | 
|  | 446 | 1785 |  |                 await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  |  | 1786 |  |             } | 
|  |  | 1787 |  |             // Send Request | 
|  | 446 | 1788 |  |             if (_shouldTrace) | 
|  |  | 1789 |  |             { | 
|  | 0 | 1790 |  |                 ServiceClientTracing.SendRequest(_invocationId, _httpRequest); | 
|  |  | 1791 |  |             } | 
|  | 446 | 1792 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 446 | 1793 |  |             _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  | 446 | 1794 |  |             if (_shouldTrace) | 
|  |  | 1795 |  |             { | 
|  | 0 | 1796 |  |                 ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); | 
|  |  | 1797 |  |             } | 
|  | 446 | 1798 |  |             HttpStatusCode _statusCode = _httpResponse.StatusCode; | 
|  | 446 | 1799 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 446 | 1800 |  |             string _responseContent = null; | 
|  | 446 | 1801 |  |             if ((int)_statusCode != 200 && (int)_statusCode != 207) | 
|  |  | 1802 |  |             { | 
|  | 2 | 1803 |  |                 var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode | 
|  |  | 1804 |  |                 try | 
|  |  | 1805 |  |                 { | 
|  | 2 | 1806 |  |                     _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  | 2 | 1807 |  |                     CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC | 
|  | 2 | 1808 |  |                     if (_errorBody != null) | 
|  |  | 1809 |  |                     { | 
|  | 2 | 1810 |  |                         ex = new CloudException(_errorBody.Message); | 
|  | 2 | 1811 |  |                         ex.Body = _errorBody; | 
|  |  | 1812 |  |                     } | 
|  | 2 | 1813 |  |                 } | 
|  | 0 | 1814 |  |                 catch (JsonException) | 
|  |  | 1815 |  |                 { | 
|  |  | 1816 |  |                     // Ignore the exception | 
|  | 0 | 1817 |  |                 } | 
|  | 2 | 1818 |  |                 ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); | 
|  | 2 | 1819 |  |                 ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); | 
|  | 2 | 1820 |  |                 if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 1821 |  |                 { | 
|  | 2 | 1822 |  |                     ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 1823 |  |                 } | 
|  | 2 | 1824 |  |                 if (_shouldTrace) | 
|  |  | 1825 |  |                 { | 
|  | 0 | 1826 |  |                     ServiceClientTracing.Error(_invocationId, ex); | 
|  |  | 1827 |  |                 } | 
|  | 2 | 1828 |  |                 _httpRequest.Dispose(); | 
|  | 2 | 1829 |  |                 if (_httpResponse != null) | 
|  |  | 1830 |  |                 { | 
|  | 2 | 1831 |  |                     _httpResponse.Dispose(); | 
|  |  | 1832 |  |                 } | 
|  | 2 | 1833 |  |                 throw ex; | 
|  |  | 1834 |  |             } | 
|  |  | 1835 |  |             // Create Result | 
|  | 444 | 1836 |  |             var _result = new AzureOperationResponse<DocumentIndexResult>(); | 
|  | 444 | 1837 |  |             _result.Request = _httpRequest; | 
|  | 444 | 1838 |  |             _result.Response = _httpResponse; | 
|  | 444 | 1839 |  |             if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 1840 |  |             { | 
|  | 444 | 1841 |  |                 _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 1842 |  |             } | 
|  |  | 1843 |  |             // Deserialize Response | 
|  | 444 | 1844 |  |             if ((int)_statusCode == 200) | 
|  |  | 1845 |  |             { | 
|  | 436 | 1846 |  |                 _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  |  | 1847 |  |                 try | 
|  |  | 1848 |  |                 { | 
|  | 436 | 1849 |  |                     _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<DocumentIndexResult>(_responseCo | 
|  | 436 | 1850 |  |                 } | 
|  | 0 | 1851 |  |                 catch (JsonException ex) | 
|  |  | 1852 |  |                 { | 
|  | 0 | 1853 |  |                     _httpRequest.Dispose(); | 
|  | 0 | 1854 |  |                     if (_httpResponse != null) | 
|  |  | 1855 |  |                     { | 
|  | 0 | 1856 |  |                         _httpResponse.Dispose(); | 
|  |  | 1857 |  |                     } | 
|  | 0 | 1858 |  |                     throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); | 
|  |  | 1859 |  |                 } | 
|  |  | 1860 |  |             } | 
|  |  | 1861 |  |             // Deserialize Response | 
|  | 444 | 1862 |  |             if ((int)_statusCode == 207) | 
|  |  | 1863 |  |             { | 
|  | 8 | 1864 |  |                 _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  |  | 1865 |  |                 try | 
|  |  | 1866 |  |                 { | 
|  | 8 | 1867 |  |                     _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<DocumentIndexResult>(_responseCo | 
|  | 8 | 1868 |  |                 } | 
|  | 0 | 1869 |  |                 catch (JsonException ex) | 
|  |  | 1870 |  |                 { | 
|  | 0 | 1871 |  |                     _httpRequest.Dispose(); | 
|  | 0 | 1872 |  |                     if (_httpResponse != null) | 
|  |  | 1873 |  |                     { | 
|  | 0 | 1874 |  |                         _httpResponse.Dispose(); | 
|  |  | 1875 |  |                     } | 
|  | 0 | 1876 |  |                     throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); | 
|  |  | 1877 |  |                 } | 
|  |  | 1878 |  |             } | 
|  | 444 | 1879 |  |             if (_shouldTrace) | 
|  |  | 1880 |  |             { | 
|  | 0 | 1881 |  |                 ServiceClientTracing.Exit(_invocationId, _result); | 
|  |  | 1882 |  |             } | 
|  | 444 | 1883 |  |             return _result; | 
|  | 444 | 1884 |  |         } | 
|  |  | 1885 |  |  | 
|  |  | 1886 |  |         /// <summary> | 
|  |  | 1887 |  |         /// Autocompletes incomplete query terms based on input text and matching terms | 
|  |  | 1888 |  |         /// in the index. | 
|  |  | 1889 |  |         /// <see href="https://docs.microsoft.com/rest/api/searchservice/autocomplete" /> | 
|  |  | 1890 |  |         /// </summary> | 
|  |  | 1891 |  |         /// <param name='searchText'> | 
|  |  | 1892 |  |         /// The incomplete term which should be auto-completed. | 
|  |  | 1893 |  |         /// </param> | 
|  |  | 1894 |  |         /// <param name='suggesterName'> | 
|  |  | 1895 |  |         /// The name of the suggester as specified in the suggesters collection that's | 
|  |  | 1896 |  |         /// part of the index definition. | 
|  |  | 1897 |  |         /// </param> | 
|  |  | 1898 |  |         /// <param name='searchRequestOptions'> | 
|  |  | 1899 |  |         /// Additional parameters for the operation | 
|  |  | 1900 |  |         /// </param> | 
|  |  | 1901 |  |         /// <param name='autocompleteParameters'> | 
|  |  | 1902 |  |         /// Additional parameters for the operation | 
|  |  | 1903 |  |         /// </param> | 
|  |  | 1904 |  |         /// <param name='customHeaders'> | 
|  |  | 1905 |  |         /// Headers that will be added to request. | 
|  |  | 1906 |  |         /// </param> | 
|  |  | 1907 |  |         /// <param name='cancellationToken'> | 
|  |  | 1908 |  |         /// The cancellation token. | 
|  |  | 1909 |  |         /// </param> | 
|  |  | 1910 |  |         /// <exception cref="CloudException"> | 
|  |  | 1911 |  |         /// Thrown when the operation returned an invalid status code | 
|  |  | 1912 |  |         /// </exception> | 
|  |  | 1913 |  |         /// <exception cref="SerializationException"> | 
|  |  | 1914 |  |         /// Thrown when unable to deserialize the response | 
|  |  | 1915 |  |         /// </exception> | 
|  |  | 1916 |  |         /// <exception cref="ValidationException"> | 
|  |  | 1917 |  |         /// Thrown when a required parameter is null | 
|  |  | 1918 |  |         /// </exception> | 
|  |  | 1919 |  |         /// <exception cref="System.ArgumentNullException"> | 
|  |  | 1920 |  |         /// Thrown when a required parameter is null | 
|  |  | 1921 |  |         /// </exception> | 
|  |  | 1922 |  |         /// <return> | 
|  |  | 1923 |  |         /// A response object containing the response body and response headers. | 
|  |  | 1924 |  |         /// </return> | 
|  |  | 1925 |  |         public async Task<AzureOperationResponse<AutocompleteResult>> AutocompleteGetWithHttpMessagesAsync(string search | 
|  |  | 1926 |  |         { | 
|  | 38 | 1927 |  |             if (Client.SearchServiceName == null) | 
|  |  | 1928 |  |             { | 
|  | 0 | 1929 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName"); | 
|  |  | 1930 |  |             } | 
|  | 38 | 1931 |  |             if (Client.SearchDnsSuffix == null) | 
|  |  | 1932 |  |             { | 
|  | 0 | 1933 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix"); | 
|  |  | 1934 |  |             } | 
|  | 38 | 1935 |  |             if (Client.IndexName == null) | 
|  |  | 1936 |  |             { | 
|  | 0 | 1937 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.IndexName"); | 
|  |  | 1938 |  |             } | 
|  | 38 | 1939 |  |             if (Client.ApiVersion == null) | 
|  |  | 1940 |  |             { | 
|  | 0 | 1941 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); | 
|  |  | 1942 |  |             } | 
|  | 38 | 1943 |  |             if (searchText == null) | 
|  |  | 1944 |  |             { | 
|  | 0 | 1945 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "searchText"); | 
|  |  | 1946 |  |             } | 
|  | 38 | 1947 |  |             if (suggesterName == null) | 
|  |  | 1948 |  |             { | 
|  | 0 | 1949 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "suggesterName"); | 
|  |  | 1950 |  |             } | 
|  | 38 | 1951 |  |             System.Guid? clientRequestId = default(System.Guid?); | 
|  | 38 | 1952 |  |             if (searchRequestOptions != null) | 
|  |  | 1953 |  |             { | 
|  | 0 | 1954 |  |                 clientRequestId = searchRequestOptions.ClientRequestId; | 
|  |  | 1955 |  |             } | 
|  | 38 | 1956 |  |             AutocompleteMode autocompleteMode = default(AutocompleteMode); | 
|  | 38 | 1957 |  |             if (autocompleteParameters != null) | 
|  |  | 1958 |  |             { | 
|  | 32 | 1959 |  |                 autocompleteMode = autocompleteParameters.AutocompleteMode; | 
|  |  | 1960 |  |             } | 
|  | 38 | 1961 |  |             string filter = default(string); | 
|  | 38 | 1962 |  |             if (autocompleteParameters != null) | 
|  |  | 1963 |  |             { | 
|  | 32 | 1964 |  |                 filter = autocompleteParameters.Filter; | 
|  |  | 1965 |  |             } | 
|  | 38 | 1966 |  |             bool? useFuzzyMatching = default(bool?); | 
|  | 38 | 1967 |  |             if (autocompleteParameters != null) | 
|  |  | 1968 |  |             { | 
|  | 32 | 1969 |  |                 useFuzzyMatching = autocompleteParameters.UseFuzzyMatching; | 
|  |  | 1970 |  |             } | 
|  | 38 | 1971 |  |             string highlightPostTag = default(string); | 
|  | 38 | 1972 |  |             if (autocompleteParameters != null) | 
|  |  | 1973 |  |             { | 
|  | 32 | 1974 |  |                 highlightPostTag = autocompleteParameters.HighlightPostTag; | 
|  |  | 1975 |  |             } | 
|  | 38 | 1976 |  |             string highlightPreTag = default(string); | 
|  | 38 | 1977 |  |             if (autocompleteParameters != null) | 
|  |  | 1978 |  |             { | 
|  | 32 | 1979 |  |                 highlightPreTag = autocompleteParameters.HighlightPreTag; | 
|  |  | 1980 |  |             } | 
|  | 38 | 1981 |  |             double? minimumCoverage = default(double?); | 
|  | 38 | 1982 |  |             if (autocompleteParameters != null) | 
|  |  | 1983 |  |             { | 
|  | 32 | 1984 |  |                 minimumCoverage = autocompleteParameters.MinimumCoverage; | 
|  |  | 1985 |  |             } | 
|  | 38 | 1986 |  |             IList<string> searchFields = default(IList<string>); | 
|  | 38 | 1987 |  |             if (autocompleteParameters != null) | 
|  |  | 1988 |  |             { | 
|  | 32 | 1989 |  |                 searchFields = autocompleteParameters.SearchFields; | 
|  |  | 1990 |  |             } | 
|  | 38 | 1991 |  |             int? top = default(int?); | 
|  | 38 | 1992 |  |             if (autocompleteParameters != null) | 
|  |  | 1993 |  |             { | 
|  | 32 | 1994 |  |                 top = autocompleteParameters.Top; | 
|  |  | 1995 |  |             } | 
|  |  | 1996 |  |             // Tracing | 
|  | 38 | 1997 |  |             bool _shouldTrace = ServiceClientTracing.IsEnabled; | 
|  | 38 | 1998 |  |             string _invocationId = null; | 
|  | 38 | 1999 |  |             if (_shouldTrace) | 
|  |  | 2000 |  |             { | 
|  | 0 | 2001 |  |                 _invocationId = ServiceClientTracing.NextInvocationId.ToString(); | 
|  | 0 | 2002 |  |                 Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); | 
|  | 0 | 2003 |  |                 tracingParameters.Add("searchText", searchText); | 
|  | 0 | 2004 |  |                 tracingParameters.Add("suggesterName", suggesterName); | 
|  | 0 | 2005 |  |                 tracingParameters.Add("clientRequestId", clientRequestId); | 
|  | 0 | 2006 |  |                 tracingParameters.Add("autocompleteMode", autocompleteMode); | 
|  | 0 | 2007 |  |                 tracingParameters.Add("filter", filter); | 
|  | 0 | 2008 |  |                 tracingParameters.Add("useFuzzyMatching", useFuzzyMatching); | 
|  | 0 | 2009 |  |                 tracingParameters.Add("highlightPostTag", highlightPostTag); | 
|  | 0 | 2010 |  |                 tracingParameters.Add("highlightPreTag", highlightPreTag); | 
|  | 0 | 2011 |  |                 tracingParameters.Add("minimumCoverage", minimumCoverage); | 
|  | 0 | 2012 |  |                 tracingParameters.Add("searchFields", searchFields); | 
|  | 0 | 2013 |  |                 tracingParameters.Add("top", top); | 
|  | 0 | 2014 |  |                 tracingParameters.Add("cancellationToken", cancellationToken); | 
|  | 0 | 2015 |  |                 ServiceClientTracing.Enter(_invocationId, this, "AutocompleteGet", tracingParameters); | 
|  |  | 2016 |  |             } | 
|  |  | 2017 |  |             // Construct URL | 
|  | 38 | 2018 |  |             var _baseUrl = Client.BaseUri; | 
|  | 38 | 2019 |  |             var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "docs/search.autocomplete"; | 
|  | 38 | 2020 |  |             _url = _url.Replace("{searchServiceName}", Client.SearchServiceName); | 
|  | 38 | 2021 |  |             _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix); | 
|  | 38 | 2022 |  |             _url = _url.Replace("{indexName}", Client.IndexName); | 
|  | 38 | 2023 |  |             List<string> _queryParameters = new List<string>(); | 
|  | 38 | 2024 |  |             if (Client.ApiVersion != null) | 
|  |  | 2025 |  |             { | 
|  | 38 | 2026 |  |                 _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); | 
|  |  | 2027 |  |             } | 
|  | 38 | 2028 |  |             if (searchText != null) | 
|  |  | 2029 |  |             { | 
|  | 38 | 2030 |  |                 _queryParameters.Add(string.Format("search={0}", System.Uri.EscapeDataString(searchText))); | 
|  |  | 2031 |  |             } | 
|  | 38 | 2032 |  |             if (suggesterName != null) | 
|  |  | 2033 |  |             { | 
|  | 38 | 2034 |  |                 _queryParameters.Add(string.Format("suggesterName={0}", System.Uri.EscapeDataString(suggesterName))); | 
|  |  | 2035 |  |             } | 
|  | 38 | 2036 |  |             _queryParameters.Add(string.Format("autocompleteMode={0}", System.Uri.EscapeDataString(Rest.Serialization.Sa | 
|  | 38 | 2037 |  |             if (filter != null) | 
|  |  | 2038 |  |             { | 
|  | 8 | 2039 |  |                 _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); | 
|  |  | 2040 |  |             } | 
|  | 38 | 2041 |  |             if (useFuzzyMatching != null) | 
|  |  | 2042 |  |             { | 
|  | 10 | 2043 |  |                 _queryParameters.Add(string.Format("fuzzy={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonC | 
|  |  | 2044 |  |             } | 
|  | 38 | 2045 |  |             if (highlightPostTag != null) | 
|  |  | 2046 |  |             { | 
|  | 2 | 2047 |  |                 _queryParameters.Add(string.Format("highlightPostTag={0}", System.Uri.EscapeDataString(highlightPostTag) | 
|  |  | 2048 |  |             } | 
|  | 38 | 2049 |  |             if (highlightPreTag != null) | 
|  |  | 2050 |  |             { | 
|  | 2 | 2051 |  |                 _queryParameters.Add(string.Format("highlightPreTag={0}", System.Uri.EscapeDataString(highlightPreTag))) | 
|  |  | 2052 |  |             } | 
|  | 38 | 2053 |  |             if (minimumCoverage != null) | 
|  |  | 2054 |  |             { | 
|  | 0 | 2055 |  |                 _queryParameters.Add(string.Format("minimumCoverage={0}", System.Uri.EscapeDataString(Rest.Serialization | 
|  |  | 2056 |  |             } | 
|  | 38 | 2057 |  |             if (searchFields != null) | 
|  |  | 2058 |  |             { | 
|  | 6 | 2059 |  |                 _queryParameters.Add(string.Format("searchFields={0}", System.Uri.EscapeDataString(string.Join(",", sear | 
|  |  | 2060 |  |             } | 
|  | 38 | 2061 |  |             if (top != null) | 
|  |  | 2062 |  |             { | 
|  | 2 | 2063 |  |                 _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo | 
|  |  | 2064 |  |             } | 
|  | 38 | 2065 |  |             if (_queryParameters.Count > 0) | 
|  |  | 2066 |  |             { | 
|  | 38 | 2067 |  |                 _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); | 
|  |  | 2068 |  |             } | 
|  |  | 2069 |  |             // Create HTTP transport objects | 
|  | 38 | 2070 |  |             var _httpRequest = new HttpRequestMessage(); | 
|  | 38 | 2071 |  |             HttpResponseMessage _httpResponse = null; | 
|  | 38 | 2072 |  |             _httpRequest.Method = new HttpMethod("GET"); | 
|  | 38 | 2073 |  |             _httpRequest.RequestUri = new System.Uri(_url); | 
|  |  | 2074 |  |             // Set Headers | 
|  | 38 | 2075 |  |             if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) | 
|  |  | 2076 |  |             { | 
|  | 38 | 2077 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); | 
|  |  | 2078 |  |             } | 
|  | 38 | 2079 |  |             if (Client.AcceptLanguage != null) | 
|  |  | 2080 |  |             { | 
|  | 38 | 2081 |  |                 if (_httpRequest.Headers.Contains("accept-language")) | 
|  |  | 2082 |  |                 { | 
|  | 0 | 2083 |  |                     _httpRequest.Headers.Remove("accept-language"); | 
|  |  | 2084 |  |                 } | 
|  | 38 | 2085 |  |                 _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); | 
|  |  | 2086 |  |             } | 
|  | 38 | 2087 |  |             if (clientRequestId != null) | 
|  |  | 2088 |  |             { | 
|  | 0 | 2089 |  |                 if (_httpRequest.Headers.Contains("client-request-id")) | 
|  |  | 2090 |  |                 { | 
|  | 0 | 2091 |  |                     _httpRequest.Headers.Remove("client-request-id"); | 
|  |  | 2092 |  |                 } | 
|  | 0 | 2093 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser | 
|  |  | 2094 |  |             } | 
|  |  | 2095 |  |  | 
|  |  | 2096 |  |  | 
|  | 38 | 2097 |  |             if (customHeaders != null) | 
|  |  | 2098 |  |             { | 
|  | 0 | 2099 |  |                 foreach(var _header in customHeaders) | 
|  |  | 2100 |  |                 { | 
|  | 0 | 2101 |  |                     if (_httpRequest.Headers.Contains(_header.Key)) | 
|  |  | 2102 |  |                     { | 
|  | 0 | 2103 |  |                         _httpRequest.Headers.Remove(_header.Key); | 
|  |  | 2104 |  |                     } | 
|  | 0 | 2105 |  |                     _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); | 
|  |  | 2106 |  |                 } | 
|  |  | 2107 |  |             } | 
|  |  | 2108 |  |  | 
|  |  | 2109 |  |             // Serialize Request | 
|  | 38 | 2110 |  |             string _requestContent = null; | 
|  |  | 2111 |  |             // Set Credentials | 
|  | 38 | 2112 |  |             if (Client.Credentials != null) | 
|  |  | 2113 |  |             { | 
|  | 38 | 2114 |  |                 cancellationToken.ThrowIfCancellationRequested(); | 
|  | 38 | 2115 |  |                 await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  |  | 2116 |  |             } | 
|  |  | 2117 |  |             // Send Request | 
|  | 38 | 2118 |  |             if (_shouldTrace) | 
|  |  | 2119 |  |             { | 
|  | 0 | 2120 |  |                 ServiceClientTracing.SendRequest(_invocationId, _httpRequest); | 
|  |  | 2121 |  |             } | 
|  | 38 | 2122 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 38 | 2123 |  |             _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  | 38 | 2124 |  |             if (_shouldTrace) | 
|  |  | 2125 |  |             { | 
|  | 0 | 2126 |  |                 ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); | 
|  |  | 2127 |  |             } | 
|  | 38 | 2128 |  |             HttpStatusCode _statusCode = _httpResponse.StatusCode; | 
|  | 38 | 2129 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 38 | 2130 |  |             string _responseContent = null; | 
|  | 38 | 2131 |  |             if ((int)_statusCode != 200) | 
|  |  | 2132 |  |             { | 
|  | 4 | 2133 |  |                 var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode | 
|  |  | 2134 |  |                 try | 
|  |  | 2135 |  |                 { | 
|  | 4 | 2136 |  |                     _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  | 4 | 2137 |  |                     CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC | 
|  | 4 | 2138 |  |                     if (_errorBody != null) | 
|  |  | 2139 |  |                     { | 
|  | 4 | 2140 |  |                         ex = new CloudException(_errorBody.Message); | 
|  | 4 | 2141 |  |                         ex.Body = _errorBody; | 
|  |  | 2142 |  |                     } | 
|  | 4 | 2143 |  |                 } | 
|  | 0 | 2144 |  |                 catch (JsonException) | 
|  |  | 2145 |  |                 { | 
|  |  | 2146 |  |                     // Ignore the exception | 
|  | 0 | 2147 |  |                 } | 
|  | 4 | 2148 |  |                 ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); | 
|  | 4 | 2149 |  |                 ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); | 
|  | 4 | 2150 |  |                 if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 2151 |  |                 { | 
|  | 4 | 2152 |  |                     ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 2153 |  |                 } | 
|  | 4 | 2154 |  |                 if (_shouldTrace) | 
|  |  | 2155 |  |                 { | 
|  | 0 | 2156 |  |                     ServiceClientTracing.Error(_invocationId, ex); | 
|  |  | 2157 |  |                 } | 
|  | 4 | 2158 |  |                 _httpRequest.Dispose(); | 
|  | 4 | 2159 |  |                 if (_httpResponse != null) | 
|  |  | 2160 |  |                 { | 
|  | 4 | 2161 |  |                     _httpResponse.Dispose(); | 
|  |  | 2162 |  |                 } | 
|  | 4 | 2163 |  |                 throw ex; | 
|  |  | 2164 |  |             } | 
|  |  | 2165 |  |             // Create Result | 
|  | 34 | 2166 |  |             var _result = new AzureOperationResponse<AutocompleteResult>(); | 
|  | 34 | 2167 |  |             _result.Request = _httpRequest; | 
|  | 34 | 2168 |  |             _result.Response = _httpResponse; | 
|  | 34 | 2169 |  |             if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 2170 |  |             { | 
|  | 34 | 2171 |  |                 _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 2172 |  |             } | 
|  |  | 2173 |  |             // Deserialize Response | 
|  | 34 | 2174 |  |             if ((int)_statusCode == 200) | 
|  |  | 2175 |  |             { | 
|  | 34 | 2176 |  |                 _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  |  | 2177 |  |                 try | 
|  |  | 2178 |  |                 { | 
|  | 34 | 2179 |  |                     _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<AutocompleteResult>(_responseCon | 
|  | 34 | 2180 |  |                 } | 
|  | 0 | 2181 |  |                 catch (JsonException ex) | 
|  |  | 2182 |  |                 { | 
|  | 0 | 2183 |  |                     _httpRequest.Dispose(); | 
|  | 0 | 2184 |  |                     if (_httpResponse != null) | 
|  |  | 2185 |  |                     { | 
|  | 0 | 2186 |  |                         _httpResponse.Dispose(); | 
|  |  | 2187 |  |                     } | 
|  | 0 | 2188 |  |                     throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); | 
|  |  | 2189 |  |                 } | 
|  |  | 2190 |  |             } | 
|  | 34 | 2191 |  |             if (_shouldTrace) | 
|  |  | 2192 |  |             { | 
|  | 0 | 2193 |  |                 ServiceClientTracing.Exit(_invocationId, _result); | 
|  |  | 2194 |  |             } | 
|  | 34 | 2195 |  |             return _result; | 
|  | 34 | 2196 |  |         } | 
|  |  | 2197 |  |  | 
|  |  | 2198 |  |         /// <summary> | 
|  |  | 2199 |  |         /// Autocompletes incomplete query terms based on input text and matching terms | 
|  |  | 2200 |  |         /// in the index. | 
|  |  | 2201 |  |         /// <see href="https://docs.microsoft.com/rest/api/searchservice/autocomplete" /> | 
|  |  | 2202 |  |         /// </summary> | 
|  |  | 2203 |  |         /// <param name='autocompleteRequest'> | 
|  |  | 2204 |  |         /// The definition of the Autocomplete request. | 
|  |  | 2205 |  |         /// </param> | 
|  |  | 2206 |  |         /// <param name='searchRequestOptions'> | 
|  |  | 2207 |  |         /// Additional parameters for the operation | 
|  |  | 2208 |  |         /// </param> | 
|  |  | 2209 |  |         /// <param name='customHeaders'> | 
|  |  | 2210 |  |         /// Headers that will be added to request. | 
|  |  | 2211 |  |         /// </param> | 
|  |  | 2212 |  |         /// <param name='cancellationToken'> | 
|  |  | 2213 |  |         /// The cancellation token. | 
|  |  | 2214 |  |         /// </param> | 
|  |  | 2215 |  |         /// <exception cref="CloudException"> | 
|  |  | 2216 |  |         /// Thrown when the operation returned an invalid status code | 
|  |  | 2217 |  |         /// </exception> | 
|  |  | 2218 |  |         /// <exception cref="SerializationException"> | 
|  |  | 2219 |  |         /// Thrown when unable to deserialize the response | 
|  |  | 2220 |  |         /// </exception> | 
|  |  | 2221 |  |         /// <exception cref="ValidationException"> | 
|  |  | 2222 |  |         /// Thrown when a required parameter is null | 
|  |  | 2223 |  |         /// </exception> | 
|  |  | 2224 |  |         /// <exception cref="System.ArgumentNullException"> | 
|  |  | 2225 |  |         /// Thrown when a required parameter is null | 
|  |  | 2226 |  |         /// </exception> | 
|  |  | 2227 |  |         /// <return> | 
|  |  | 2228 |  |         /// A response object containing the response body and response headers. | 
|  |  | 2229 |  |         /// </return> | 
|  |  | 2230 |  |         public async Task<AzureOperationResponse<AutocompleteResult>> AutocompletePostWithHttpMessagesAsync(Autocomplete | 
|  |  | 2231 |  |         { | 
|  | 38 | 2232 |  |             if (Client.SearchServiceName == null) | 
|  |  | 2233 |  |             { | 
|  | 0 | 2234 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName"); | 
|  |  | 2235 |  |             } | 
|  | 38 | 2236 |  |             if (Client.SearchDnsSuffix == null) | 
|  |  | 2237 |  |             { | 
|  | 0 | 2238 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix"); | 
|  |  | 2239 |  |             } | 
|  | 38 | 2240 |  |             if (Client.IndexName == null) | 
|  |  | 2241 |  |             { | 
|  | 0 | 2242 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.IndexName"); | 
|  |  | 2243 |  |             } | 
|  | 38 | 2244 |  |             if (Client.ApiVersion == null) | 
|  |  | 2245 |  |             { | 
|  | 0 | 2246 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); | 
|  |  | 2247 |  |             } | 
|  | 38 | 2248 |  |             if (autocompleteRequest == null) | 
|  |  | 2249 |  |             { | 
|  | 0 | 2250 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "autocompleteRequest"); | 
|  |  | 2251 |  |             } | 
|  | 38 | 2252 |  |             System.Guid? clientRequestId = default(System.Guid?); | 
|  | 38 | 2253 |  |             if (searchRequestOptions != null) | 
|  |  | 2254 |  |             { | 
|  | 0 | 2255 |  |                 clientRequestId = searchRequestOptions.ClientRequestId; | 
|  |  | 2256 |  |             } | 
|  |  | 2257 |  |             // Tracing | 
|  | 38 | 2258 |  |             bool _shouldTrace = ServiceClientTracing.IsEnabled; | 
|  | 38 | 2259 |  |             string _invocationId = null; | 
|  | 38 | 2260 |  |             if (_shouldTrace) | 
|  |  | 2261 |  |             { | 
|  | 0 | 2262 |  |                 _invocationId = ServiceClientTracing.NextInvocationId.ToString(); | 
|  | 0 | 2263 |  |                 Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); | 
|  | 0 | 2264 |  |                 tracingParameters.Add("autocompleteRequest", autocompleteRequest); | 
|  | 0 | 2265 |  |                 tracingParameters.Add("clientRequestId", clientRequestId); | 
|  | 0 | 2266 |  |                 tracingParameters.Add("cancellationToken", cancellationToken); | 
|  | 0 | 2267 |  |                 ServiceClientTracing.Enter(_invocationId, this, "AutocompletePost", tracingParameters); | 
|  |  | 2268 |  |             } | 
|  |  | 2269 |  |             // Construct URL | 
|  | 38 | 2270 |  |             var _baseUrl = Client.BaseUri; | 
|  | 38 | 2271 |  |             var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "docs/search.post.autocomplete"; | 
|  | 38 | 2272 |  |             _url = _url.Replace("{searchServiceName}", Client.SearchServiceName); | 
|  | 38 | 2273 |  |             _url = _url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix); | 
|  | 38 | 2274 |  |             _url = _url.Replace("{indexName}", Client.IndexName); | 
|  | 38 | 2275 |  |             List<string> _queryParameters = new List<string>(); | 
|  | 38 | 2276 |  |             if (Client.ApiVersion != null) | 
|  |  | 2277 |  |             { | 
|  | 38 | 2278 |  |                 _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); | 
|  |  | 2279 |  |             } | 
|  | 38 | 2280 |  |             if (_queryParameters.Count > 0) | 
|  |  | 2281 |  |             { | 
|  | 38 | 2282 |  |                 _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); | 
|  |  | 2283 |  |             } | 
|  |  | 2284 |  |             // Create HTTP transport objects | 
|  | 38 | 2285 |  |             var _httpRequest = new HttpRequestMessage(); | 
|  | 38 | 2286 |  |             HttpResponseMessage _httpResponse = null; | 
|  | 38 | 2287 |  |             _httpRequest.Method = new HttpMethod("POST"); | 
|  | 38 | 2288 |  |             _httpRequest.RequestUri = new System.Uri(_url); | 
|  |  | 2289 |  |             // Set Headers | 
|  | 38 | 2290 |  |             if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) | 
|  |  | 2291 |  |             { | 
|  | 38 | 2292 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", System.Guid.NewGuid().ToString()); | 
|  |  | 2293 |  |             } | 
|  | 38 | 2294 |  |             if (Client.AcceptLanguage != null) | 
|  |  | 2295 |  |             { | 
|  | 38 | 2296 |  |                 if (_httpRequest.Headers.Contains("accept-language")) | 
|  |  | 2297 |  |                 { | 
|  | 0 | 2298 |  |                     _httpRequest.Headers.Remove("accept-language"); | 
|  |  | 2299 |  |                 } | 
|  | 38 | 2300 |  |                 _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); | 
|  |  | 2301 |  |             } | 
|  | 38 | 2302 |  |             if (clientRequestId != null) | 
|  |  | 2303 |  |             { | 
|  | 0 | 2304 |  |                 if (_httpRequest.Headers.Contains("client-request-id")) | 
|  |  | 2305 |  |                 { | 
|  | 0 | 2306 |  |                     _httpRequest.Headers.Remove("client-request-id"); | 
|  |  | 2307 |  |                 } | 
|  | 0 | 2308 |  |                 _httpRequest.Headers.TryAddWithoutValidation("client-request-id", Rest.Serialization.SafeJsonConvert.Ser | 
|  |  | 2309 |  |             } | 
|  |  | 2310 |  |  | 
|  |  | 2311 |  |  | 
|  | 38 | 2312 |  |             if (customHeaders != null) | 
|  |  | 2313 |  |             { | 
|  | 0 | 2314 |  |                 foreach(var _header in customHeaders) | 
|  |  | 2315 |  |                 { | 
|  | 0 | 2316 |  |                     if (_httpRequest.Headers.Contains(_header.Key)) | 
|  |  | 2317 |  |                     { | 
|  | 0 | 2318 |  |                         _httpRequest.Headers.Remove(_header.Key); | 
|  |  | 2319 |  |                     } | 
|  | 0 | 2320 |  |                     _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); | 
|  |  | 2321 |  |                 } | 
|  |  | 2322 |  |             } | 
|  |  | 2323 |  |  | 
|  |  | 2324 |  |             // Serialize Request | 
|  | 38 | 2325 |  |             string _requestContent = null; | 
|  | 38 | 2326 |  |             if(autocompleteRequest != null) | 
|  |  | 2327 |  |             { | 
|  | 38 | 2328 |  |                 _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(autocompleteRequest, requestSeriali | 
|  | 38 | 2329 |  |                 _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); | 
|  | 38 | 2330 |  |                 _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio | 
|  |  | 2331 |  |             } | 
|  |  | 2332 |  |             // Set Credentials | 
|  | 38 | 2333 |  |             if (Client.Credentials != null) | 
|  |  | 2334 |  |             { | 
|  | 38 | 2335 |  |                 cancellationToken.ThrowIfCancellationRequested(); | 
|  | 38 | 2336 |  |                 await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  |  | 2337 |  |             } | 
|  |  | 2338 |  |             // Send Request | 
|  | 38 | 2339 |  |             if (_shouldTrace) | 
|  |  | 2340 |  |             { | 
|  | 0 | 2341 |  |                 ServiceClientTracing.SendRequest(_invocationId, _httpRequest); | 
|  |  | 2342 |  |             } | 
|  | 38 | 2343 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 38 | 2344 |  |             _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); | 
|  | 38 | 2345 |  |             if (_shouldTrace) | 
|  |  | 2346 |  |             { | 
|  | 0 | 2347 |  |                 ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); | 
|  |  | 2348 |  |             } | 
|  | 38 | 2349 |  |             HttpStatusCode _statusCode = _httpResponse.StatusCode; | 
|  | 38 | 2350 |  |             cancellationToken.ThrowIfCancellationRequested(); | 
|  | 38 | 2351 |  |             string _responseContent = null; | 
|  | 38 | 2352 |  |             if ((int)_statusCode != 200) | 
|  |  | 2353 |  |             { | 
|  | 4 | 2354 |  |                 var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode | 
|  |  | 2355 |  |                 try | 
|  |  | 2356 |  |                 { | 
|  | 4 | 2357 |  |                     _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  | 4 | 2358 |  |                     CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC | 
|  | 4 | 2359 |  |                     if (_errorBody != null) | 
|  |  | 2360 |  |                     { | 
|  | 4 | 2361 |  |                         ex = new CloudException(_errorBody.Message); | 
|  | 4 | 2362 |  |                         ex.Body = _errorBody; | 
|  |  | 2363 |  |                     } | 
|  | 4 | 2364 |  |                 } | 
|  | 0 | 2365 |  |                 catch (JsonException) | 
|  |  | 2366 |  |                 { | 
|  |  | 2367 |  |                     // Ignore the exception | 
|  | 0 | 2368 |  |                 } | 
|  | 4 | 2369 |  |                 ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); | 
|  | 4 | 2370 |  |                 ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); | 
|  | 4 | 2371 |  |                 if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 2372 |  |                 { | 
|  | 4 | 2373 |  |                     ex.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 2374 |  |                 } | 
|  | 4 | 2375 |  |                 if (_shouldTrace) | 
|  |  | 2376 |  |                 { | 
|  | 0 | 2377 |  |                     ServiceClientTracing.Error(_invocationId, ex); | 
|  |  | 2378 |  |                 } | 
|  | 4 | 2379 |  |                 _httpRequest.Dispose(); | 
|  | 4 | 2380 |  |                 if (_httpResponse != null) | 
|  |  | 2381 |  |                 { | 
|  | 4 | 2382 |  |                     _httpResponse.Dispose(); | 
|  |  | 2383 |  |                 } | 
|  | 4 | 2384 |  |                 throw ex; | 
|  |  | 2385 |  |             } | 
|  |  | 2386 |  |             // Create Result | 
|  | 34 | 2387 |  |             var _result = new AzureOperationResponse<AutocompleteResult>(); | 
|  | 34 | 2388 |  |             _result.Request = _httpRequest; | 
|  | 34 | 2389 |  |             _result.Response = _httpResponse; | 
|  | 34 | 2390 |  |             if (_httpResponse.Headers.Contains("request-id")) | 
|  |  | 2391 |  |             { | 
|  | 34 | 2392 |  |                 _result.RequestId = _httpResponse.Headers.GetValues("request-id").FirstOrDefault(); | 
|  |  | 2393 |  |             } | 
|  |  | 2394 |  |             // Deserialize Response | 
|  | 34 | 2395 |  |             if ((int)_statusCode == 200) | 
|  |  | 2396 |  |             { | 
|  | 34 | 2397 |  |                 _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); | 
|  |  | 2398 |  |                 try | 
|  |  | 2399 |  |                 { | 
|  | 34 | 2400 |  |                     _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<AutocompleteResult>(_responseCon | 
|  | 34 | 2401 |  |                 } | 
|  | 0 | 2402 |  |                 catch (JsonException ex) | 
|  |  | 2403 |  |                 { | 
|  | 0 | 2404 |  |                     _httpRequest.Dispose(); | 
|  | 0 | 2405 |  |                     if (_httpResponse != null) | 
|  |  | 2406 |  |                     { | 
|  | 0 | 2407 |  |                         _httpResponse.Dispose(); | 
|  |  | 2408 |  |                     } | 
|  | 0 | 2409 |  |                     throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); | 
|  |  | 2410 |  |                 } | 
|  |  | 2411 |  |             } | 
|  | 34 | 2412 |  |             if (_shouldTrace) | 
|  |  | 2413 |  |             { | 
|  | 0 | 2414 |  |                 ServiceClientTracing.Exit(_invocationId, _result); | 
|  |  | 2415 |  |             } | 
|  | 34 | 2416 |  |             return _result; | 
|  | 34 | 2417 |  |         } | 
|  |  | 2418 |  |  | 
|  |  | 2419 |  |     } | 
|  |  | 2420 |  | } |