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