< Summary

Class:Microsoft.Azure.Management.Search.PrivateLinkResourcesOperations
Assembly:Microsoft.Azure.Management.Search
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Management.Search\src\Generated\PrivateLinkResourcesOperations.cs
Covered lines:4
Uncovered lines:103
Coverable lines:107
Total lines:271
Line coverage:3.7% (4 of 107)
Covered branches:1
Total branches:64
Branch coverage:1.5% (1 of 64)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-0%100%
ListSupportedWithHttpMessagesAsync()-0%0%

File(s)

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

#LineLine coverage
 1// <auto-generated>
 2// Copyright (c) Microsoft Corporation. All rights reserved.
 3// Licensed under the MIT License. See License.txt in the project root for
 4// license information.
 5//
 6// Code generated by Microsoft (R) AutoRest Code Generator.
 7// Changes may cause incorrect behavior and will be lost if the code is
 8// regenerated.
 9// </auto-generated>
 10
 11namespace Microsoft.Azure.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    /// PrivateLinkResourcesOperations operations.
 27    /// </summary>
 28    internal partial class PrivateLinkResourcesOperations : IServiceOperations<SearchManagementClient>, IPrivateLinkReso
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the PrivateLinkResourcesOperations 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>
 120439        internal PrivateLinkResourcesOperations(SearchManagementClient client)
 40        {
 120441            if (client == null)
 42            {
 043                throw new System.ArgumentNullException("client");
 44            }
 120445            Client = client;
 120446        }
 47
 48        /// <summary>
 49        /// Gets a reference to the SearchManagementClient
 50        /// </summary>
 051        public SearchManagementClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// Gets a list of all supported private link resource types for the given
 55        /// service.
 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='searchManagementRequestOptions'>
 67        /// Additional parameters for the operation
 68        /// </param>
 69        /// <param name='customHeaders'>
 70        /// Headers that will be added to request.
 71        /// </param>
 72        /// <param name='cancellationToken'>
 73        /// The cancellation token.
 74        /// </param>
 75        /// <exception cref="CloudException">
 76        /// Thrown when the operation returned an invalid status code
 77        /// </exception>
 78        /// <exception cref="SerializationException">
 79        /// Thrown when unable to deserialize the response
 80        /// </exception>
 81        /// <exception cref="ValidationException">
 82        /// Thrown when a required parameter is null
 83        /// </exception>
 84        /// <exception cref="System.ArgumentNullException">
 85        /// Thrown when a required parameter is null
 86        /// </exception>
 87        /// <return>
 88        /// A response object containing the response body and response headers.
 89        /// </return>
 90        public async Task<AzureOperationResponse<IEnumerable<PrivateLinkResource>>> ListSupportedWithHttpMessagesAsync(s
 91        {
 092            if (Client.ApiVersion == null)
 93            {
 094                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 95            }
 096            if (Client.SubscriptionId == null)
 97            {
 098                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
 99            }
 0100            if (resourceGroupName == null)
 101            {
 0102                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
 103            }
 0104            if (searchServiceName == null)
 105            {
 0106                throw new ValidationException(ValidationRules.CannotBeNull, "searchServiceName");
 107            }
 0108            System.Guid? clientRequestId = default(System.Guid?);
 0109            if (searchManagementRequestOptions != null)
 110            {
 0111                clientRequestId = searchManagementRequestOptions.ClientRequestId;
 112            }
 113            // Tracing
 0114            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0115            string _invocationId = null;
 0116            if (_shouldTrace)
 117            {
 0118                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0119                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0120                tracingParameters.Add("resourceGroupName", resourceGroupName);
 0121                tracingParameters.Add("searchServiceName", searchServiceName);
 0122                tracingParameters.Add("clientRequestId", clientRequestId);
 0123                tracingParameters.Add("cancellationToken", cancellationToken);
 0124                ServiceClientTracing.Enter(_invocationId, this, "ListSupported", tracingParameters);
 125            }
 126            // Construct URL
 0127            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0128            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{su
 0129            _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId));
 0130            _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName));
 0131            _url = _url.Replace("{searchServiceName}", System.Uri.EscapeDataString(searchServiceName));
 0132            List<string> _queryParameters = new List<string>();
 0133            if (Client.ApiVersion != null)
 134            {
 0135                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 136            }
 0137            if (_queryParameters.Count > 0)
 138            {
 0139                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 140            }
 141            // Create HTTP transport objects
 0142            var _httpRequest = new HttpRequestMessage();
 0143            HttpResponseMessage _httpResponse = null;
 0144            _httpRequest.Method = new HttpMethod("GET");
 0145            _httpRequest.RequestUri = new System.Uri(_url);
 146            // Set Headers
 0147            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 148            {
 0149                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 150            }
 0151            if (Client.AcceptLanguage != null)
 152            {
 0153                if (_httpRequest.Headers.Contains("accept-language"))
 154                {
 0155                    _httpRequest.Headers.Remove("accept-language");
 156                }
 0157                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 158            }
 0159            if (clientRequestId != null)
 160            {
 0161                if (_httpRequest.Headers.Contains("x-ms-client-request-id"))
 162                {
 0163                    _httpRequest.Headers.Remove("x-ms-client-request-id");
 164                }
 0165                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Rest.Serialization.SafeJsonConver
 166            }
 167
 168
 0169            if (customHeaders != null)
 170            {
 0171                foreach(var _header in customHeaders)
 172                {
 0173                    if (_httpRequest.Headers.Contains(_header.Key))
 174                    {
 0175                        _httpRequest.Headers.Remove(_header.Key);
 176                    }
 0177                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 178                }
 179            }
 180
 181            // Serialize Request
 0182            string _requestContent = null;
 183            // Set Credentials
 0184            if (Client.Credentials != null)
 185            {
 0186                cancellationToken.ThrowIfCancellationRequested();
 0187                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 188            }
 189            // Send Request
 0190            if (_shouldTrace)
 191            {
 0192                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 193            }
 0194            cancellationToken.ThrowIfCancellationRequested();
 0195            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0196            if (_shouldTrace)
 197            {
 0198                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 199            }
 0200            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0201            cancellationToken.ThrowIfCancellationRequested();
 0202            string _responseContent = null;
 0203            if ((int)_statusCode != 200)
 204            {
 0205                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 206                try
 207                {
 0208                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0209                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0210                    if (_errorBody != null)
 211                    {
 0212                        ex = new CloudException(_errorBody.Message);
 0213                        ex.Body = _errorBody;
 214                    }
 0215                }
 0216                catch (JsonException)
 217                {
 218                    // Ignore the exception
 0219                }
 0220                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0221                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0222                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 223                {
 0224                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 225                }
 0226                if (_shouldTrace)
 227                {
 0228                    ServiceClientTracing.Error(_invocationId, ex);
 229                }
 0230                _httpRequest.Dispose();
 0231                if (_httpResponse != null)
 232                {
 0233                    _httpResponse.Dispose();
 234                }
 0235                throw ex;
 236            }
 237            // Create Result
 0238            var _result = new AzureOperationResponse<IEnumerable<PrivateLinkResource>>();
 0239            _result.Request = _httpRequest;
 0240            _result.Response = _httpResponse;
 0241            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 242            {
 0243                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 244            }
 245            // Deserialize Response
 0246            if ((int)_statusCode == 200)
 247            {
 0248                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 249                try
 250                {
 0251                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<PrivateLinkResource>>(_resp
 0252                }
 0253                catch (JsonException ex)
 254                {
 0255                    _httpRequest.Dispose();
 0256                    if (_httpResponse != null)
 257                    {
 0258                        _httpResponse.Dispose();
 259                    }
 0260                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 261                }
 262            }
 0263            if (_shouldTrace)
 264            {
 0265                ServiceClientTracing.Exit(_invocationId, _result);
 266            }
 0267            return _result;
 0268        }
 269
 270    }
 271}