| | 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.Management.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 | | /// SharedPrivateLinkResourcesOperations operations. |
| | 27 | | /// </summary> |
| | 28 | | internal partial class SharedPrivateLinkResourcesOperations : IServiceOperations<SearchManagementClient>, ISharedPri |
| | 29 | | { |
| | 30 | | /// <summary> |
| | 31 | | /// Initializes a new instance of the SharedPrivateLinkResourcesOperations 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> |
| 1204 | 39 | | internal SharedPrivateLinkResourcesOperations(SearchManagementClient client) |
| | 40 | | { |
| 1204 | 41 | | if (client == null) |
| | 42 | | { |
| 0 | 43 | | throw new System.ArgumentNullException("client"); |
| | 44 | | } |
| 1204 | 45 | | Client = client; |
| 1204 | 46 | | } |
| | 47 | |
|
| | 48 | | /// <summary> |
| | 49 | | /// Gets a reference to the SearchManagementClient |
| | 50 | | /// </summary> |
| 0 | 51 | | public SearchManagementClient Client { get; private set; } |
| | 52 | |
|
| | 53 | | /// <summary> |
| | 54 | | /// Creates or updates a shared private link resource managed by the Search |
| | 55 | | /// service in the given resource group. |
| | 56 | | /// <see href="https://aka.ms/search-manage" /> |
| | 57 | | /// </summary> |
| | 58 | | /// <param name='resourceGroupName'> |
| | 59 | | /// The name of the resource group within the current subscription. You can |
| | 60 | | /// obtain this value from the Azure Resource Manager API or the portal. |
| | 61 | | /// </param> |
| | 62 | | /// <param name='searchServiceName'> |
| | 63 | | /// The name of the Azure Cognitive Search service associated with the |
| | 64 | | /// specified resource group. |
| | 65 | | /// </param> |
| | 66 | | /// <param name='sharedPrivateLinkResourceName'> |
| | 67 | | /// The name of the shared private link resource managed by the Azure Cognitive |
| | 68 | | /// Search service within the specified resource group. |
| | 69 | | /// </param> |
| | 70 | | /// <param name='sharedPrivateLinkResource'> |
| | 71 | | /// The definition of the shared private link resource to create or update. |
| | 72 | | /// </param> |
| | 73 | | /// <param name='searchManagementRequestOptions'> |
| | 74 | | /// Additional parameters for the operation |
| | 75 | | /// </param> |
| | 76 | | /// <param name='customHeaders'> |
| | 77 | | /// Headers that will be added to request. |
| | 78 | | /// </param> |
| | 79 | | /// <param name='cancellationToken'> |
| | 80 | | /// The cancellation token. |
| | 81 | | /// </param> |
| | 82 | | /// <exception cref="CloudException"> |
| | 83 | | /// Thrown when the operation returned an invalid status code |
| | 84 | | /// </exception> |
| | 85 | | /// <exception cref="SerializationException"> |
| | 86 | | /// Thrown when unable to deserialize the response |
| | 87 | | /// </exception> |
| | 88 | | /// <exception cref="ValidationException"> |
| | 89 | | /// Thrown when a required parameter is null |
| | 90 | | /// </exception> |
| | 91 | | /// <exception cref="System.ArgumentNullException"> |
| | 92 | | /// Thrown when a required parameter is null |
| | 93 | | /// </exception> |
| | 94 | | /// <return> |
| | 95 | | /// A response object containing the response body and response headers. |
| | 96 | | /// </return> |
| | 97 | | public async Task<AzureOperationResponse<SharedPrivateLinkResource>> CreateOrUpdateWithHttpMessagesAsync(string |
| | 98 | | { |
| 0 | 99 | | if (resourceGroupName == null) |
| | 100 | | { |
| 0 | 101 | | throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); |
| | 102 | | } |
| 0 | 103 | | if (searchServiceName == null) |
| | 104 | | { |
| 0 | 105 | | throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName"); |
| | 106 | | } |
| 0 | 107 | | if (sharedPrivateLinkResourceName == null) |
| | 108 | | { |
| 0 | 109 | | throw new ValidationException(ValidationRules.CannotBeNull, "sharedPrivateLinkResourceName"); |
| | 110 | | } |
| 0 | 111 | | if (sharedPrivateLinkResource == null) |
| | 112 | | { |
| 0 | 113 | | throw new ValidationException(ValidationRules.CannotBeNull, "sharedPrivateLinkResource"); |
| | 114 | | } |
| 0 | 115 | | if (Client.ApiVersion == null) |
| | 116 | | { |
| 0 | 117 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 118 | | } |
| 0 | 119 | | if (Client.SubscriptionId == null) |
| | 120 | | { |
| 0 | 121 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); |
| | 122 | | } |
| 0 | 123 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 124 | | if (searchManagementRequestOptions != null) |
| | 125 | | { |
| 0 | 126 | | clientRequestId = searchManagementRequestOptions.ClientRequestId; |
| | 127 | | } |
| | 128 | | // Tracing |
| 0 | 129 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 130 | | string _invocationId = null; |
| 0 | 131 | | if (_shouldTrace) |
| | 132 | | { |
| 0 | 133 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 134 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 135 | | tracingParameters.Add("resourceGroupName", resourceGroupName); |
| 0 | 136 | | tracingParameters.Add("searchServiceName", searchServiceName); |
| 0 | 137 | | tracingParameters.Add("sharedPrivateLinkResourceName", sharedPrivateLinkResourceName); |
| 0 | 138 | | tracingParameters.Add("sharedPrivateLinkResource", sharedPrivateLinkResource); |
| 0 | 139 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 140 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 141 | | ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); |
| | 142 | | } |
| | 143 | | // Construct URL |
| 0 | 144 | | var _baseUrl = Client.BaseUri.AbsoluteUri; |
| 0 | 145 | | var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su |
| 0 | 146 | | _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); |
| 0 | 147 | | _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName)); |
| 0 | 148 | | _url = _url.Replace("{sharedPrivateLinkResourceName}", System.Uri.EscapeDataString(sharedPrivateLinkResource |
| 0 | 149 | | _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); |
| 0 | 150 | | List<string> _queryParameters = new List<string>(); |
| 0 | 151 | | if (Client.ApiVersion != null) |
| | 152 | | { |
| 0 | 153 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 154 | | } |
| 0 | 155 | | if (_queryParameters.Count > 0) |
| | 156 | | { |
| 0 | 157 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 158 | | } |
| | 159 | | // Create HTTP transport objects |
| 0 | 160 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 161 | | HttpResponseMessage _httpResponse = null; |
| 0 | 162 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 0 | 163 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 164 | | // Set Headers |
| 0 | 165 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 166 | | { |
| 0 | 167 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()) |
| | 168 | | } |
| 0 | 169 | | if (Client.AcceptLanguage != null) |
| | 170 | | { |
| 0 | 171 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 172 | | { |
| 0 | 173 | | _httpRequest.Headers.Remove("accept-language"); |
| | 174 | | } |
| 0 | 175 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 176 | | } |
| 0 | 177 | | if (clientRequestId != null) |
| | 178 | | { |
| 0 | 179 | | if (_httpRequest.Headers.Contains("x-ms-client-request-id")) |
| | 180 | | { |
| 0 | 181 | | _httpRequest.Headers.Remove("x-ms-client-request-id"); |
| | 182 | | } |
| 0 | 183 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver |
| | 184 | | } |
| | 185 | |
|
| | 186 | |
|
| 0 | 187 | | if (customHeaders != null) |
| | 188 | | { |
| 0 | 189 | | foreach(var _header in customHeaders) |
| | 190 | | { |
| 0 | 191 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 192 | | { |
| 0 | 193 | | _httpRequest.Headers.Remove(_header.Key); |
| | 194 | | } |
| 0 | 195 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 196 | | } |
| | 197 | | } |
| | 198 | |
|
| | 199 | | // Serialize Request |
| 0 | 200 | | string _requestContent = null; |
| 0 | 201 | | if(sharedPrivateLinkResource != null) |
| | 202 | | { |
| 0 | 203 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(sharedPrivateLinkResource, Client.S |
| 0 | 204 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 205 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 206 | | } |
| | 207 | | // Set Credentials |
| 0 | 208 | | if (Client.Credentials != null) |
| | 209 | | { |
| 0 | 210 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 211 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 212 | | } |
| | 213 | | // Send Request |
| 0 | 214 | | if (_shouldTrace) |
| | 215 | | { |
| 0 | 216 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 217 | | } |
| 0 | 218 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 219 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 220 | | if (_shouldTrace) |
| | 221 | | { |
| 0 | 222 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 223 | | } |
| 0 | 224 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 225 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 226 | | string _responseContent = null; |
| 0 | 227 | | if ((int)_statusCode != 200 && (int)_statusCode != 201) |
| | 228 | | { |
| 0 | 229 | | var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode |
| | 230 | | try |
| | 231 | | { |
| 0 | 232 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 233 | | CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC |
| 0 | 234 | | if (_errorBody != null) |
| | 235 | | { |
| 0 | 236 | | ex = new CloudException(_errorBody.Message); |
| 0 | 237 | | ex.Body = _errorBody; |
| | 238 | | } |
| 0 | 239 | | } |
| 0 | 240 | | catch (JsonException) |
| | 241 | | { |
| | 242 | | // Ignore the exception |
| 0 | 243 | | } |
| 0 | 244 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 245 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 246 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 247 | | { |
| 0 | 248 | | ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 249 | | } |
| 0 | 250 | | if (_shouldTrace) |
| | 251 | | { |
| 0 | 252 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 253 | | } |
| 0 | 254 | | _httpRequest.Dispose(); |
| 0 | 255 | | if (_httpResponse != null) |
| | 256 | | { |
| 0 | 257 | | _httpResponse.Dispose(); |
| | 258 | | } |
| 0 | 259 | | throw ex; |
| | 260 | | } |
| | 261 | | // Create Result |
| 0 | 262 | | var _result = new AzureOperationResponse<SharedPrivateLinkResource>(); |
| 0 | 263 | | _result.Request = _httpRequest; |
| 0 | 264 | | _result.Response = _httpResponse; |
| 0 | 265 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 266 | | { |
| 0 | 267 | | _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 268 | | } |
| | 269 | | // Deserialize Response |
| 0 | 270 | | if ((int)_statusCode == 200) |
| | 271 | | { |
| 0 | 272 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 273 | | try |
| | 274 | | { |
| 0 | 275 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SharedPrivateLinkResource>(_resp |
| 0 | 276 | | } |
| 0 | 277 | | catch (JsonException ex) |
| | 278 | | { |
| 0 | 279 | | _httpRequest.Dispose(); |
| 0 | 280 | | if (_httpResponse != null) |
| | 281 | | { |
| 0 | 282 | | _httpResponse.Dispose(); |
| | 283 | | } |
| 0 | 284 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 285 | | } |
| | 286 | | } |
| | 287 | | // Deserialize Response |
| 0 | 288 | | if ((int)_statusCode == 201) |
| | 289 | | { |
| 0 | 290 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 291 | | try |
| | 292 | | { |
| 0 | 293 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SharedPrivateLinkResource>(_resp |
| 0 | 294 | | } |
| 0 | 295 | | catch (JsonException ex) |
| | 296 | | { |
| 0 | 297 | | _httpRequest.Dispose(); |
| 0 | 298 | | if (_httpResponse != null) |
| | 299 | | { |
| 0 | 300 | | _httpResponse.Dispose(); |
| | 301 | | } |
| 0 | 302 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 303 | | } |
| | 304 | | } |
| 0 | 305 | | if (_shouldTrace) |
| | 306 | | { |
| 0 | 307 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 308 | | } |
| 0 | 309 | | return _result; |
| 0 | 310 | | } |
| | 311 | |
|
| | 312 | | /// <summary> |
| | 313 | | /// Gets the details of the shared private link resource managed by the Search |
| | 314 | | /// service in the given resource group. |
| | 315 | | /// <see href="https://aka.ms/search-manage" /> |
| | 316 | | /// </summary> |
| | 317 | | /// <param name='resourceGroupName'> |
| | 318 | | /// The name of the resource group within the current subscription. You can |
| | 319 | | /// obtain this value from the Azure Resource Manager API or the portal. |
| | 320 | | /// </param> |
| | 321 | | /// <param name='searchServiceName'> |
| | 322 | | /// The name of the Azure Cognitive Search service associated with the |
| | 323 | | /// specified resource group. |
| | 324 | | /// </param> |
| | 325 | | /// <param name='sharedPrivateLinkResourceName'> |
| | 326 | | /// The name of the shared private link resource managed by the Azure Cognitive |
| | 327 | | /// Search service within the specified resource group. |
| | 328 | | /// </param> |
| | 329 | | /// <param name='searchManagementRequestOptions'> |
| | 330 | | /// Additional parameters for the operation |
| | 331 | | /// </param> |
| | 332 | | /// <param name='customHeaders'> |
| | 333 | | /// Headers that will be added to request. |
| | 334 | | /// </param> |
| | 335 | | /// <param name='cancellationToken'> |
| | 336 | | /// The cancellation token. |
| | 337 | | /// </param> |
| | 338 | | /// <exception cref="CloudException"> |
| | 339 | | /// Thrown when the operation returned an invalid status code |
| | 340 | | /// </exception> |
| | 341 | | /// <exception cref="SerializationException"> |
| | 342 | | /// Thrown when unable to deserialize the response |
| | 343 | | /// </exception> |
| | 344 | | /// <exception cref="ValidationException"> |
| | 345 | | /// Thrown when a required parameter is null |
| | 346 | | /// </exception> |
| | 347 | | /// <exception cref="System.ArgumentNullException"> |
| | 348 | | /// Thrown when a required parameter is null |
| | 349 | | /// </exception> |
| | 350 | | /// <return> |
| | 351 | | /// A response object containing the response body and response headers. |
| | 352 | | /// </return> |
| | 353 | | public async Task<AzureOperationResponse<SharedPrivateLinkResource>> GetWithHttpMessagesAsync(string resourceGro |
| | 354 | | { |
| 0 | 355 | | if (resourceGroupName == null) |
| | 356 | | { |
| 0 | 357 | | throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); |
| | 358 | | } |
| 0 | 359 | | if (searchServiceName == null) |
| | 360 | | { |
| 0 | 361 | | throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName"); |
| | 362 | | } |
| 0 | 363 | | if (sharedPrivateLinkResourceName == null) |
| | 364 | | { |
| 0 | 365 | | throw new ValidationException(ValidationRules.CannotBeNull, "sharedPrivateLinkResourceName"); |
| | 366 | | } |
| 0 | 367 | | if (Client.ApiVersion == null) |
| | 368 | | { |
| 0 | 369 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 370 | | } |
| 0 | 371 | | if (Client.SubscriptionId == null) |
| | 372 | | { |
| 0 | 373 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); |
| | 374 | | } |
| 0 | 375 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 376 | | if (searchManagementRequestOptions != null) |
| | 377 | | { |
| 0 | 378 | | clientRequestId = searchManagementRequestOptions.ClientRequestId; |
| | 379 | | } |
| | 380 | | // Tracing |
| 0 | 381 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 382 | | string _invocationId = null; |
| 0 | 383 | | if (_shouldTrace) |
| | 384 | | { |
| 0 | 385 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 386 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 387 | | tracingParameters.Add("resourceGroupName", resourceGroupName); |
| 0 | 388 | | tracingParameters.Add("searchServiceName", searchServiceName); |
| 0 | 389 | | tracingParameters.Add("sharedPrivateLinkResourceName", sharedPrivateLinkResourceName); |
| 0 | 390 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 391 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 392 | | ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); |
| | 393 | | } |
| | 394 | | // Construct URL |
| 0 | 395 | | var _baseUrl = Client.BaseUri.AbsoluteUri; |
| 0 | 396 | | var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su |
| 0 | 397 | | _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); |
| 0 | 398 | | _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName)); |
| 0 | 399 | | _url = _url.Replace("{sharedPrivateLinkResourceName}", System.Uri.EscapeDataString(sharedPrivateLinkResource |
| 0 | 400 | | _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); |
| 0 | 401 | | List<string> _queryParameters = new List<string>(); |
| 0 | 402 | | if (Client.ApiVersion != null) |
| | 403 | | { |
| 0 | 404 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 405 | | } |
| 0 | 406 | | if (_queryParameters.Count > 0) |
| | 407 | | { |
| 0 | 408 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 409 | | } |
| | 410 | | // Create HTTP transport objects |
| 0 | 411 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 412 | | HttpResponseMessage _httpResponse = null; |
| 0 | 413 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 414 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 415 | | // Set Headers |
| 0 | 416 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 417 | | { |
| 0 | 418 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()) |
| | 419 | | } |
| 0 | 420 | | if (Client.AcceptLanguage != null) |
| | 421 | | { |
| 0 | 422 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 423 | | { |
| 0 | 424 | | _httpRequest.Headers.Remove("accept-language"); |
| | 425 | | } |
| 0 | 426 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 427 | | } |
| 0 | 428 | | if (clientRequestId != null) |
| | 429 | | { |
| 0 | 430 | | if (_httpRequest.Headers.Contains("x-ms-client-request-id")) |
| | 431 | | { |
| 0 | 432 | | _httpRequest.Headers.Remove("x-ms-client-request-id"); |
| | 433 | | } |
| 0 | 434 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver |
| | 435 | | } |
| | 436 | |
|
| | 437 | |
|
| 0 | 438 | | if (customHeaders != null) |
| | 439 | | { |
| 0 | 440 | | foreach(var _header in customHeaders) |
| | 441 | | { |
| 0 | 442 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 443 | | { |
| 0 | 444 | | _httpRequest.Headers.Remove(_header.Key); |
| | 445 | | } |
| 0 | 446 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 447 | | } |
| | 448 | | } |
| | 449 | |
|
| | 450 | | // Serialize Request |
| 0 | 451 | | string _requestContent = null; |
| | 452 | | // Set Credentials |
| 0 | 453 | | if (Client.Credentials != null) |
| | 454 | | { |
| 0 | 455 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 456 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 457 | | } |
| | 458 | | // Send Request |
| 0 | 459 | | if (_shouldTrace) |
| | 460 | | { |
| 0 | 461 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 462 | | } |
| 0 | 463 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 464 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 465 | | if (_shouldTrace) |
| | 466 | | { |
| 0 | 467 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 468 | | } |
| 0 | 469 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 470 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 471 | | string _responseContent = null; |
| 0 | 472 | | if ((int)_statusCode != 200) |
| | 473 | | { |
| 0 | 474 | | var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode |
| | 475 | | try |
| | 476 | | { |
| 0 | 477 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 478 | | CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC |
| 0 | 479 | | if (_errorBody != null) |
| | 480 | | { |
| 0 | 481 | | ex = new CloudException(_errorBody.Message); |
| 0 | 482 | | ex.Body = _errorBody; |
| | 483 | | } |
| 0 | 484 | | } |
| 0 | 485 | | catch (JsonException) |
| | 486 | | { |
| | 487 | | // Ignore the exception |
| 0 | 488 | | } |
| 0 | 489 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 490 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 491 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 492 | | { |
| 0 | 493 | | ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 494 | | } |
| 0 | 495 | | if (_shouldTrace) |
| | 496 | | { |
| 0 | 497 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 498 | | } |
| 0 | 499 | | _httpRequest.Dispose(); |
| 0 | 500 | | if (_httpResponse != null) |
| | 501 | | { |
| 0 | 502 | | _httpResponse.Dispose(); |
| | 503 | | } |
| 0 | 504 | | throw ex; |
| | 505 | | } |
| | 506 | | // Create Result |
| 0 | 507 | | var _result = new AzureOperationResponse<SharedPrivateLinkResource>(); |
| 0 | 508 | | _result.Request = _httpRequest; |
| 0 | 509 | | _result.Response = _httpResponse; |
| 0 | 510 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 511 | | { |
| 0 | 512 | | _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 513 | | } |
| | 514 | | // Deserialize Response |
| 0 | 515 | | if ((int)_statusCode == 200) |
| | 516 | | { |
| 0 | 517 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 518 | | try |
| | 519 | | { |
| 0 | 520 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<SharedPrivateLinkResource>(_resp |
| 0 | 521 | | } |
| 0 | 522 | | catch (JsonException ex) |
| | 523 | | { |
| 0 | 524 | | _httpRequest.Dispose(); |
| 0 | 525 | | if (_httpResponse != null) |
| | 526 | | { |
| 0 | 527 | | _httpResponse.Dispose(); |
| | 528 | | } |
| 0 | 529 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 530 | | } |
| | 531 | | } |
| 0 | 532 | | if (_shouldTrace) |
| | 533 | | { |
| 0 | 534 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 535 | | } |
| 0 | 536 | | return _result; |
| 0 | 537 | | } |
| | 538 | |
|
| | 539 | | /// <summary> |
| | 540 | | /// Deletes the shared private link resource from the Search service. |
| | 541 | | /// <see href="https://aka.ms/search-manage" /> |
| | 542 | | /// </summary> |
| | 543 | | /// <param name='resourceGroupName'> |
| | 544 | | /// The name of the resource group within the current subscription. You can |
| | 545 | | /// obtain this value from the Azure Resource Manager API or the portal. |
| | 546 | | /// </param> |
| | 547 | | /// <param name='searchServiceName'> |
| | 548 | | /// The name of the Azure Cognitive Search service associated with the |
| | 549 | | /// specified resource group. |
| | 550 | | /// </param> |
| | 551 | | /// <param name='sharedPrivateLinkResourceName'> |
| | 552 | | /// The name of the shared private link resource managed by the Azure Cognitive |
| | 553 | | /// Search service within the specified resource group. |
| | 554 | | /// </param> |
| | 555 | | /// <param name='searchManagementRequestOptions'> |
| | 556 | | /// Additional parameters for the operation |
| | 557 | | /// </param> |
| | 558 | | /// <param name='customHeaders'> |
| | 559 | | /// Headers that will be added to request. |
| | 560 | | /// </param> |
| | 561 | | /// <param name='cancellationToken'> |
| | 562 | | /// The cancellation token. |
| | 563 | | /// </param> |
| | 564 | | /// <exception cref="CloudException"> |
| | 565 | | /// Thrown when the operation returned an invalid status code |
| | 566 | | /// </exception> |
| | 567 | | /// <exception cref="ValidationException"> |
| | 568 | | /// Thrown when a required parameter is null |
| | 569 | | /// </exception> |
| | 570 | | /// <exception cref="System.ArgumentNullException"> |
| | 571 | | /// Thrown when a required parameter is null |
| | 572 | | /// </exception> |
| | 573 | | /// <return> |
| | 574 | | /// A response object containing the response body and response headers. |
| | 575 | | /// </return> |
| | 576 | | public async Task<AzureOperationResponse> DeleteWithHttpMessagesAsync(string resourceGroupName, string searchSer |
| | 577 | | { |
| 0 | 578 | | if (resourceGroupName == null) |
| | 579 | | { |
| 0 | 580 | | throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); |
| | 581 | | } |
| 0 | 582 | | if (searchServiceName == null) |
| | 583 | | { |
| 0 | 584 | | throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName"); |
| | 585 | | } |
| 0 | 586 | | if (sharedPrivateLinkResourceName == null) |
| | 587 | | { |
| 0 | 588 | | throw new ValidationException(ValidationRules.CannotBeNull, "sharedPrivateLinkResourceName"); |
| | 589 | | } |
| 0 | 590 | | if (Client.ApiVersion == null) |
| | 591 | | { |
| 0 | 592 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 593 | | } |
| 0 | 594 | | if (Client.SubscriptionId == null) |
| | 595 | | { |
| 0 | 596 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); |
| | 597 | | } |
| 0 | 598 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 599 | | if (searchManagementRequestOptions != null) |
| | 600 | | { |
| 0 | 601 | | clientRequestId = searchManagementRequestOptions.ClientRequestId; |
| | 602 | | } |
| | 603 | | // Tracing |
| 0 | 604 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 605 | | string _invocationId = null; |
| 0 | 606 | | if (_shouldTrace) |
| | 607 | | { |
| 0 | 608 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 609 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 610 | | tracingParameters.Add("resourceGroupName", resourceGroupName); |
| 0 | 611 | | tracingParameters.Add("searchServiceName", searchServiceName); |
| 0 | 612 | | tracingParameters.Add("sharedPrivateLinkResourceName", sharedPrivateLinkResourceName); |
| 0 | 613 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 614 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 615 | | ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); |
| | 616 | | } |
| | 617 | | // Construct URL |
| 0 | 618 | | var _baseUrl = Client.BaseUri.AbsoluteUri; |
| 0 | 619 | | var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su |
| 0 | 620 | | _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); |
| 0 | 621 | | _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName)); |
| 0 | 622 | | _url = _url.Replace("{sharedPrivateLinkResourceName}", System.Uri.EscapeDataString(sharedPrivateLinkResource |
| 0 | 623 | | _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); |
| 0 | 624 | | List<string> _queryParameters = new List<string>(); |
| 0 | 625 | | if (Client.ApiVersion != null) |
| | 626 | | { |
| 0 | 627 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 628 | | } |
| 0 | 629 | | if (_queryParameters.Count > 0) |
| | 630 | | { |
| 0 | 631 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 632 | | } |
| | 633 | | // Create HTTP transport objects |
| 0 | 634 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 635 | | HttpResponseMessage _httpResponse = null; |
| 0 | 636 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 0 | 637 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 638 | | // Set Headers |
| 0 | 639 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 640 | | { |
| 0 | 641 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()) |
| | 642 | | } |
| 0 | 643 | | if (Client.AcceptLanguage != null) |
| | 644 | | { |
| 0 | 645 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 646 | | { |
| 0 | 647 | | _httpRequest.Headers.Remove("accept-language"); |
| | 648 | | } |
| 0 | 649 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 650 | | } |
| 0 | 651 | | if (clientRequestId != null) |
| | 652 | | { |
| 0 | 653 | | if (_httpRequest.Headers.Contains("x-ms-client-request-id")) |
| | 654 | | { |
| 0 | 655 | | _httpRequest.Headers.Remove("x-ms-client-request-id"); |
| | 656 | | } |
| 0 | 657 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver |
| | 658 | | } |
| | 659 | |
|
| | 660 | |
|
| 0 | 661 | | if (customHeaders != null) |
| | 662 | | { |
| 0 | 663 | | foreach(var _header in customHeaders) |
| | 664 | | { |
| 0 | 665 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 666 | | { |
| 0 | 667 | | _httpRequest.Headers.Remove(_header.Key); |
| | 668 | | } |
| 0 | 669 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 670 | | } |
| | 671 | | } |
| | 672 | |
|
| | 673 | | // Serialize Request |
| 0 | 674 | | string _requestContent = null; |
| | 675 | | // Set Credentials |
| 0 | 676 | | if (Client.Credentials != null) |
| | 677 | | { |
| 0 | 678 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 679 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 680 | | } |
| | 681 | | // Send Request |
| 0 | 682 | | if (_shouldTrace) |
| | 683 | | { |
| 0 | 684 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 685 | | } |
| 0 | 686 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 687 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 688 | | if (_shouldTrace) |
| | 689 | | { |
| 0 | 690 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 691 | | } |
| 0 | 692 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 693 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 694 | | string _responseContent = null; |
| 0 | 695 | | if ((int)_statusCode != 200 && (int)_statusCode != 404) |
| | 696 | | { |
| 0 | 697 | | var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode |
| | 698 | | try |
| | 699 | | { |
| 0 | 700 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 701 | | CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC |
| 0 | 702 | | if (_errorBody != null) |
| | 703 | | { |
| 0 | 704 | | ex = new CloudException(_errorBody.Message); |
| 0 | 705 | | ex.Body = _errorBody; |
| | 706 | | } |
| 0 | 707 | | } |
| 0 | 708 | | catch (JsonException) |
| | 709 | | { |
| | 710 | | // Ignore the exception |
| 0 | 711 | | } |
| 0 | 712 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 713 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 714 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 715 | | { |
| 0 | 716 | | ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 717 | | } |
| 0 | 718 | | if (_shouldTrace) |
| | 719 | | { |
| 0 | 720 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 721 | | } |
| 0 | 722 | | _httpRequest.Dispose(); |
| 0 | 723 | | if (_httpResponse != null) |
| | 724 | | { |
| 0 | 725 | | _httpResponse.Dispose(); |
| | 726 | | } |
| 0 | 727 | | throw ex; |
| | 728 | | } |
| | 729 | | // Create Result |
| 0 | 730 | | var _result = new AzureOperationResponse(); |
| 0 | 731 | | _result.Request = _httpRequest; |
| 0 | 732 | | _result.Response = _httpResponse; |
| 0 | 733 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 734 | | { |
| 0 | 735 | | _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 736 | | } |
| 0 | 737 | | if (_shouldTrace) |
| | 738 | | { |
| 0 | 739 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 740 | | } |
| 0 | 741 | | return _result; |
| 0 | 742 | | } |
| | 743 | |
|
| | 744 | | /// <summary> |
| | 745 | | /// Gets a list of all shared private link resources managed by the given |
| | 746 | | /// service. |
| | 747 | | /// <see href="https://aka.ms/search-manage" /> |
| | 748 | | /// </summary> |
| | 749 | | /// <param name='resourceGroupName'> |
| | 750 | | /// The name of the resource group within the current subscription. You can |
| | 751 | | /// obtain this value from the Azure Resource Manager API or the portal. |
| | 752 | | /// </param> |
| | 753 | | /// <param name='searchServiceName'> |
| | 754 | | /// The name of the Azure Cognitive Search service associated with the |
| | 755 | | /// specified resource group. |
| | 756 | | /// </param> |
| | 757 | | /// <param name='searchManagementRequestOptions'> |
| | 758 | | /// Additional parameters for the operation |
| | 759 | | /// </param> |
| | 760 | | /// <param name='customHeaders'> |
| | 761 | | /// Headers that will be added to request. |
| | 762 | | /// </param> |
| | 763 | | /// <param name='cancellationToken'> |
| | 764 | | /// The cancellation token. |
| | 765 | | /// </param> |
| | 766 | | /// <exception cref="CloudException"> |
| | 767 | | /// Thrown when the operation returned an invalid status code |
| | 768 | | /// </exception> |
| | 769 | | /// <exception cref="SerializationException"> |
| | 770 | | /// Thrown when unable to deserialize the response |
| | 771 | | /// </exception> |
| | 772 | | /// <exception cref="ValidationException"> |
| | 773 | | /// Thrown when a required parameter is null |
| | 774 | | /// </exception> |
| | 775 | | /// <exception cref="System.ArgumentNullException"> |
| | 776 | | /// Thrown when a required parameter is null |
| | 777 | | /// </exception> |
| | 778 | | /// <return> |
| | 779 | | /// A response object containing the response body and response headers. |
| | 780 | | /// </return> |
| | 781 | | public async Task<AzureOperationResponse<IPage<SharedPrivateLinkResource>>> ListByServiceWithHttpMessagesAsync(s |
| | 782 | | { |
| 0 | 783 | | if (Client.ApiVersion == null) |
| | 784 | | { |
| 0 | 785 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 786 | | } |
| 0 | 787 | | if (Client.SubscriptionId == null) |
| | 788 | | { |
| 0 | 789 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); |
| | 790 | | } |
| 0 | 791 | | if (resourceGroupName == null) |
| | 792 | | { |
| 0 | 793 | | throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); |
| | 794 | | } |
| 0 | 795 | | if (searchServiceName == null) |
| | 796 | | { |
| 0 | 797 | | throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName"); |
| | 798 | | } |
| 0 | 799 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 800 | | if (searchManagementRequestOptions != null) |
| | 801 | | { |
| 0 | 802 | | clientRequestId = searchManagementRequestOptions.ClientRequestId; |
| | 803 | | } |
| | 804 | | // Tracing |
| 0 | 805 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 806 | | string _invocationId = null; |
| 0 | 807 | | if (_shouldTrace) |
| | 808 | | { |
| 0 | 809 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 810 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 811 | | tracingParameters.Add("resourceGroupName", resourceGroupName); |
| 0 | 812 | | tracingParameters.Add("searchServiceName", searchServiceName); |
| 0 | 813 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 814 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 815 | | ServiceClientTracing.Enter(_invocationId, this, "ListByService", tracingParameters); |
| | 816 | | } |
| | 817 | | // Construct URL |
| 0 | 818 | | var _baseUrl = Client.BaseUri.AbsoluteUri; |
| 0 | 819 | | var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su |
| 0 | 820 | | _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); |
| 0 | 821 | | _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); |
| 0 | 822 | | _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName)); |
| 0 | 823 | | List<string> _queryParameters = new List<string>(); |
| 0 | 824 | | if (Client.ApiVersion != null) |
| | 825 | | { |
| 0 | 826 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 827 | | } |
| 0 | 828 | | if (_queryParameters.Count > 0) |
| | 829 | | { |
| 0 | 830 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 831 | | } |
| | 832 | | // Create HTTP transport objects |
| 0 | 833 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 834 | | HttpResponseMessage _httpResponse = null; |
| 0 | 835 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 836 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 837 | | // Set Headers |
| 0 | 838 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 839 | | { |
| 0 | 840 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()) |
| | 841 | | } |
| 0 | 842 | | if (Client.AcceptLanguage != null) |
| | 843 | | { |
| 0 | 844 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 845 | | { |
| 0 | 846 | | _httpRequest.Headers.Remove("accept-language"); |
| | 847 | | } |
| 0 | 848 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 849 | | } |
| 0 | 850 | | if (clientRequestId != null) |
| | 851 | | { |
| 0 | 852 | | if (_httpRequest.Headers.Contains("x-ms-client-request-id")) |
| | 853 | | { |
| 0 | 854 | | _httpRequest.Headers.Remove("x-ms-client-request-id"); |
| | 855 | | } |
| 0 | 856 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver |
| | 857 | | } |
| | 858 | |
|
| | 859 | |
|
| 0 | 860 | | if (customHeaders != null) |
| | 861 | | { |
| 0 | 862 | | foreach(var _header in customHeaders) |
| | 863 | | { |
| 0 | 864 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 865 | | { |
| 0 | 866 | | _httpRequest.Headers.Remove(_header.Key); |
| | 867 | | } |
| 0 | 868 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 869 | | } |
| | 870 | | } |
| | 871 | |
|
| | 872 | | // Serialize Request |
| 0 | 873 | | string _requestContent = null; |
| | 874 | | // Set Credentials |
| 0 | 875 | | if (Client.Credentials != null) |
| | 876 | | { |
| 0 | 877 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 878 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 879 | | } |
| | 880 | | // Send Request |
| 0 | 881 | | if (_shouldTrace) |
| | 882 | | { |
| 0 | 883 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 884 | | } |
| 0 | 885 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 886 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 887 | | if (_shouldTrace) |
| | 888 | | { |
| 0 | 889 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 890 | | } |
| 0 | 891 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 892 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 893 | | string _responseContent = null; |
| 0 | 894 | | if ((int)_statusCode != 200) |
| | 895 | | { |
| 0 | 896 | | var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode |
| | 897 | | try |
| | 898 | | { |
| 0 | 899 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 900 | | CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC |
| 0 | 901 | | if (_errorBody != null) |
| | 902 | | { |
| 0 | 903 | | ex = new CloudException(_errorBody.Message); |
| 0 | 904 | | ex.Body = _errorBody; |
| | 905 | | } |
| 0 | 906 | | } |
| 0 | 907 | | catch (JsonException) |
| | 908 | | { |
| | 909 | | // Ignore the exception |
| 0 | 910 | | } |
| 0 | 911 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 912 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 913 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 914 | | { |
| 0 | 915 | | ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 916 | | } |
| 0 | 917 | | if (_shouldTrace) |
| | 918 | | { |
| 0 | 919 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 920 | | } |
| 0 | 921 | | _httpRequest.Dispose(); |
| 0 | 922 | | if (_httpResponse != null) |
| | 923 | | { |
| 0 | 924 | | _httpResponse.Dispose(); |
| | 925 | | } |
| 0 | 926 | | throw ex; |
| | 927 | | } |
| | 928 | | // Create Result |
| 0 | 929 | | var _result = new AzureOperationResponse<IPage<SharedPrivateLinkResource>>(); |
| 0 | 930 | | _result.Request = _httpRequest; |
| 0 | 931 | | _result.Response = _httpResponse; |
| 0 | 932 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 933 | | { |
| 0 | 934 | | _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 935 | | } |
| | 936 | | // Deserialize Response |
| 0 | 937 | | if ((int)_statusCode == 200) |
| | 938 | | { |
| 0 | 939 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 940 | | try |
| | 941 | | { |
| 0 | 942 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<SharedPrivateLinkResource> |
| 0 | 943 | | } |
| 0 | 944 | | catch (JsonException ex) |
| | 945 | | { |
| 0 | 946 | | _httpRequest.Dispose(); |
| 0 | 947 | | if (_httpResponse != null) |
| | 948 | | { |
| 0 | 949 | | _httpResponse.Dispose(); |
| | 950 | | } |
| 0 | 951 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 952 | | } |
| | 953 | | } |
| 0 | 954 | | if (_shouldTrace) |
| | 955 | | { |
| 0 | 956 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 957 | | } |
| 0 | 958 | | return _result; |
| 0 | 959 | | } |
| | 960 | |
|
| | 961 | | /// <summary> |
| | 962 | | /// Gets a list of all shared private link resources managed by the given |
| | 963 | | /// service. |
| | 964 | | /// <see href="https://aka.ms/search-manage" /> |
| | 965 | | /// </summary> |
| | 966 | | /// <param name='nextPageLink'> |
| | 967 | | /// The NextLink from the previous successful call to List operation. |
| | 968 | | /// </param> |
| | 969 | | /// <param name='searchManagementRequestOptions'> |
| | 970 | | /// Additional parameters for the operation |
| | 971 | | /// </param> |
| | 972 | | /// <param name='customHeaders'> |
| | 973 | | /// Headers that will be added to request. |
| | 974 | | /// </param> |
| | 975 | | /// <param name='cancellationToken'> |
| | 976 | | /// The cancellation token. |
| | 977 | | /// </param> |
| | 978 | | /// <exception cref="CloudException"> |
| | 979 | | /// Thrown when the operation returned an invalid status code |
| | 980 | | /// </exception> |
| | 981 | | /// <exception cref="SerializationException"> |
| | 982 | | /// Thrown when unable to deserialize the response |
| | 983 | | /// </exception> |
| | 984 | | /// <exception cref="ValidationException"> |
| | 985 | | /// Thrown when a required parameter is null |
| | 986 | | /// </exception> |
| | 987 | | /// <exception cref="System.ArgumentNullException"> |
| | 988 | | /// Thrown when a required parameter is null |
| | 989 | | /// </exception> |
| | 990 | | /// <return> |
| | 991 | | /// A response object containing the response body and response headers. |
| | 992 | | /// </return> |
| | 993 | | public async Task<AzureOperationResponse<IPage<SharedPrivateLinkResource>>> ListByServiceNextWithHttpMessagesAsy |
| | 994 | | { |
| 0 | 995 | | if (nextPageLink == null) |
| | 996 | | { |
| 0 | 997 | | throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); |
| | 998 | | } |
| 0 | 999 | | System.Guid? clientRequestId = default(System.Guid?); |
| 0 | 1000 | | if (searchManagementRequestOptions != null) |
| | 1001 | | { |
| 0 | 1002 | | clientRequestId = searchManagementRequestOptions.ClientRequestId; |
| | 1003 | | } |
| | 1004 | | // Tracing |
| 0 | 1005 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 1006 | | string _invocationId = null; |
| 0 | 1007 | | if (_shouldTrace) |
| | 1008 | | { |
| 0 | 1009 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 1010 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 1011 | | tracingParameters.Add("nextPageLink", nextPageLink); |
| 0 | 1012 | | tracingParameters.Add("clientRequestId", clientRequestId); |
| 0 | 1013 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1014 | | ServiceClientTracing.Enter(_invocationId, this, "ListByServiceNext", tracingParameters); |
| | 1015 | | } |
| | 1016 | | // Construct URL |
| 0 | 1017 | | string _url = "{nextLink}"; |
| 0 | 1018 | | _url = _url.Replace("{nextLink}", nextPageLink); |
| 0 | 1019 | | List<string> _queryParameters = new List<string>(); |
| 0 | 1020 | | if (_queryParameters.Count > 0) |
| | 1021 | | { |
| 0 | 1022 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 1023 | | } |
| | 1024 | | // Create HTTP transport objects |
| 0 | 1025 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 1026 | | HttpResponseMessage _httpResponse = null; |
| 0 | 1027 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 1028 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1029 | | // Set Headers |
| 0 | 1030 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 1031 | | { |
| 0 | 1032 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()) |
| | 1033 | | } |
| 0 | 1034 | | if (Client.AcceptLanguage != null) |
| | 1035 | | { |
| 0 | 1036 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 1037 | | { |
| 0 | 1038 | | _httpRequest.Headers.Remove("accept-language"); |
| | 1039 | | } |
| 0 | 1040 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 1041 | | } |
| 0 | 1042 | | if (clientRequestId != null) |
| | 1043 | | { |
| 0 | 1044 | | if (_httpRequest.Headers.Contains("x-ms-client-request-id")) |
| | 1045 | | { |
| 0 | 1046 | | _httpRequest.Headers.Remove("x-ms-client-request-id"); |
| | 1047 | | } |
| 0 | 1048 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver |
| | 1049 | | } |
| | 1050 | |
|
| | 1051 | |
|
| 0 | 1052 | | if (customHeaders != null) |
| | 1053 | | { |
| 0 | 1054 | | foreach(var _header in customHeaders) |
| | 1055 | | { |
| 0 | 1056 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 1057 | | { |
| 0 | 1058 | | _httpRequest.Headers.Remove(_header.Key); |
| | 1059 | | } |
| 0 | 1060 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 1061 | | } |
| | 1062 | | } |
| | 1063 | |
|
| | 1064 | | // Serialize Request |
| 0 | 1065 | | string _requestContent = null; |
| | 1066 | | // Set Credentials |
| 0 | 1067 | | if (Client.Credentials != null) |
| | 1068 | | { |
| 0 | 1069 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1070 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 1071 | | } |
| | 1072 | | // Send Request |
| 0 | 1073 | | if (_shouldTrace) |
| | 1074 | | { |
| 0 | 1075 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 1076 | | } |
| 0 | 1077 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1078 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 1079 | | if (_shouldTrace) |
| | 1080 | | { |
| 0 | 1081 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 1082 | | } |
| 0 | 1083 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 1084 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1085 | | string _responseContent = null; |
| 0 | 1086 | | if ((int)_statusCode != 200) |
| | 1087 | | { |
| 0 | 1088 | | var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode |
| | 1089 | | try |
| | 1090 | | { |
| 0 | 1091 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 1092 | | CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC |
| 0 | 1093 | | if (_errorBody != null) |
| | 1094 | | { |
| 0 | 1095 | | ex = new CloudException(_errorBody.Message); |
| 0 | 1096 | | ex.Body = _errorBody; |
| | 1097 | | } |
| 0 | 1098 | | } |
| 0 | 1099 | | catch (JsonException) |
| | 1100 | | { |
| | 1101 | | // Ignore the exception |
| 0 | 1102 | | } |
| 0 | 1103 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 1104 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 1105 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 1106 | | { |
| 0 | 1107 | | ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 1108 | | } |
| 0 | 1109 | | if (_shouldTrace) |
| | 1110 | | { |
| 0 | 1111 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 1112 | | } |
| 0 | 1113 | | _httpRequest.Dispose(); |
| 0 | 1114 | | if (_httpResponse != null) |
| | 1115 | | { |
| 0 | 1116 | | _httpResponse.Dispose(); |
| | 1117 | | } |
| 0 | 1118 | | throw ex; |
| | 1119 | | } |
| | 1120 | | // Create Result |
| 0 | 1121 | | var _result = new AzureOperationResponse<IPage<SharedPrivateLinkResource>>(); |
| 0 | 1122 | | _result.Request = _httpRequest; |
| 0 | 1123 | | _result.Response = _httpResponse; |
| 0 | 1124 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 1125 | | { |
| 0 | 1126 | | _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 1127 | | } |
| | 1128 | | // Deserialize Response |
| 0 | 1129 | | if ((int)_statusCode == 200) |
| | 1130 | | { |
| 0 | 1131 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 1132 | | try |
| | 1133 | | { |
| 0 | 1134 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page1<SharedPrivateLinkResource> |
| 0 | 1135 | | } |
| 0 | 1136 | | catch (JsonException ex) |
| | 1137 | | { |
| 0 | 1138 | | _httpRequest.Dispose(); |
| 0 | 1139 | | if (_httpResponse != null) |
| | 1140 | | { |
| 0 | 1141 | | _httpResponse.Dispose(); |
| | 1142 | | } |
| 0 | 1143 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 1144 | | } |
| | 1145 | | } |
| 0 | 1146 | | if (_shouldTrace) |
| | 1147 | | { |
| 0 | 1148 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 1149 | | } |
| 0 | 1150 | | return _result; |
| 0 | 1151 | | } |
| | 1152 | |
|
| | 1153 | | } |
| | 1154 | | } |