< Summary

Class:Microsoft.Azure.Graph.RBAC.ObjectsOperations
Assembly:Microsoft.Azure.Graph.RBAC
File(s):C:\Git\azure-sdk-for-net\sdk\graphrbac\Microsoft.Azure.Graph.RBAC\src\Generated\ObjectsOperations.cs
Covered lines:56
Uncovered lines:131
Coverable lines:187
Total lines:435
Line coverage:29.9% (56 of 187)
Covered branches:30
Total branches:112
Branch coverage:26.7% (30 of 112)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
get_Client()-100%100%
GetObjectsByObjectIdsWithHttpMessagesAsync()-55.43%51.79%
GetObjectsByObjectIdsNextWithHttpMessagesAsync()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\graphrbac\Microsoft.Azure.Graph.RBAC\src\Generated\ObjectsOperations.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.Graph.RBAC
 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    /// ObjectsOperations operations.
 27    /// </summary>
 28    internal partial class ObjectsOperations : IServiceOperations<GraphRbacManagementClient>, IObjectsOperations
 29    {
 30        /// <summary>
 31        /// Initializes a new instance of the ObjectsOperations 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>
 4639        internal ObjectsOperations(GraphRbacManagementClient client)
 40        {
 4641            if (client == null)
 42            {
 043                throw new System.ArgumentNullException("client");
 44            }
 4645            Client = client;
 4646        }
 47
 48        /// <summary>
 49        /// Gets a reference to the GraphRbacManagementClient
 50        /// </summary>
 13651        public GraphRbacManagementClient Client { get; private set; }
 52
 53        /// <summary>
 54        /// Gets the directory objects specified in a list of object IDs. You can also
 55        /// specify which resource collections (users, groups, etc.) should be searched
 56        /// by specifying the optional types parameter.
 57        /// </summary>
 58        /// <param name='parameters'>
 59        /// Objects filtering parameters.
 60        /// </param>
 61        /// <param name='customHeaders'>
 62        /// Headers that will be added to request.
 63        /// </param>
 64        /// <param name='cancellationToken'>
 65        /// The cancellation token.
 66        /// </param>
 67        /// <exception cref="CloudException">
 68        /// Thrown when the operation returned an invalid status code
 69        /// </exception>
 70        /// <exception cref="SerializationException">
 71        /// Thrown when unable to deserialize the response
 72        /// </exception>
 73        /// <exception cref="ValidationException">
 74        /// Thrown when a required parameter is null
 75        /// </exception>
 76        /// <exception cref="System.ArgumentNullException">
 77        /// Thrown when a required parameter is null
 78        /// </exception>
 79        /// <return>
 80        /// A response object containing the response body and response headers.
 81        /// </return>
 82        public async Task<AzureOperationResponse<IPage<DirectoryObject>>> GetObjectsByObjectIdsWithHttpMessagesAsync(Get
 83        {
 684            if (parameters == null)
 85            {
 086                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
 87            }
 688            if (Client.ApiVersion == null)
 89            {
 090                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 91            }
 692            if (Client.TenantID == null)
 93            {
 094                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 95            }
 96            // Tracing
 697            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 698            string _invocationId = null;
 699            if (_shouldTrace)
 100            {
 0101                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0102                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0103                tracingParameters.Add("parameters", parameters);
 0104                tracingParameters.Add("cancellationToken", cancellationToken);
 0105                ServiceClientTracing.Enter(_invocationId, this, "GetObjectsByObjectIds", tracingParameters);
 106            }
 107            // Construct URL
 6108            var _baseUrl = Client.BaseUri.AbsoluteUri;
 6109            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/getObj
 6110            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 6111            List<string> _queryParameters = new List<string>();
 6112            if (Client.ApiVersion != null)
 113            {
 6114                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 115            }
 6116            if (_queryParameters.Count > 0)
 117            {
 6118                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 119            }
 120            // Create HTTP transport objects
 6121            var _httpRequest = new HttpRequestMessage();
 6122            HttpResponseMessage _httpResponse = null;
 6123            _httpRequest.Method = new HttpMethod("POST");
 6124            _httpRequest.RequestUri = new System.Uri(_url);
 125            // Set Headers
 6126            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 127            {
 6128                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 129            }
 6130            if (Client.AcceptLanguage != null)
 131            {
 6132                if (_httpRequest.Headers.Contains("accept-language"))
 133                {
 0134                    _httpRequest.Headers.Remove("accept-language");
 135                }
 6136                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 137            }
 138
 139
 6140            if (customHeaders != null)
 141            {
 0142                foreach(var _header in customHeaders)
 143                {
 0144                    if (_httpRequest.Headers.Contains(_header.Key))
 145                    {
 0146                        _httpRequest.Headers.Remove(_header.Key);
 147                    }
 0148                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 149                }
 150            }
 151
 152            // Serialize Request
 6153            string _requestContent = null;
 6154            if(parameters != null)
 155            {
 6156                _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet
 6157                _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
 6158                _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio
 159            }
 160            // Set Credentials
 6161            if (Client.Credentials != null)
 162            {
 6163                cancellationToken.ThrowIfCancellationRequested();
 6164                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 165            }
 166            // Send Request
 6167            if (_shouldTrace)
 168            {
 0169                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 170            }
 6171            cancellationToken.ThrowIfCancellationRequested();
 6172            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 6173            if (_shouldTrace)
 174            {
 0175                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 176            }
 6177            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 6178            cancellationToken.ThrowIfCancellationRequested();
 6179            string _responseContent = null;
 6180            if ((int)_statusCode != 200)
 181            {
 0182                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 183                try
 184                {
 0185                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0186                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0187                    if (_errorBody != null)
 188                    {
 0189                        ex = new CloudException(_errorBody.Message);
 0190                        ex.Body = _errorBody;
 191                    }
 0192                }
 0193                catch (JsonException)
 194                {
 195                    // Ignore the exception
 0196                }
 0197                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0198                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0199                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 200                {
 0201                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 202                }
 0203                if (_shouldTrace)
 204                {
 0205                    ServiceClientTracing.Error(_invocationId, ex);
 206                }
 0207                _httpRequest.Dispose();
 0208                if (_httpResponse != null)
 209                {
 0210                    _httpResponse.Dispose();
 211                }
 0212                throw ex;
 213            }
 214            // Create Result
 6215            var _result = new AzureOperationResponse<IPage<DirectoryObject>>();
 6216            _result.Request = _httpRequest;
 6217            _result.Response = _httpResponse;
 6218            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 219            {
 0220                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 221            }
 222            // Deserialize Response
 6223            if ((int)_statusCode == 200)
 224            {
 6225                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 226                try
 227                {
 6228                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<DirectoryObject>>(_response
 6229                }
 0230                catch (JsonException ex)
 231                {
 0232                    _httpRequest.Dispose();
 0233                    if (_httpResponse != null)
 234                    {
 0235                        _httpResponse.Dispose();
 236                    }
 0237                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 238                }
 239            }
 6240            if (_shouldTrace)
 241            {
 0242                ServiceClientTracing.Exit(_invocationId, _result);
 243            }
 6244            return _result;
 6245        }
 246
 247        /// <summary>
 248        /// Gets AD group membership for the specified AD object IDs.
 249        /// </summary>
 250        /// <param name='nextLink'>
 251        /// Next link for the list operation.
 252        /// </param>
 253        /// <param name='customHeaders'>
 254        /// Headers that will be added to request.
 255        /// </param>
 256        /// <param name='cancellationToken'>
 257        /// The cancellation token.
 258        /// </param>
 259        /// <exception cref="CloudException">
 260        /// Thrown when the operation returned an invalid status code
 261        /// </exception>
 262        /// <exception cref="SerializationException">
 263        /// Thrown when unable to deserialize the response
 264        /// </exception>
 265        /// <exception cref="ValidationException">
 266        /// Thrown when a required parameter is null
 267        /// </exception>
 268        /// <exception cref="System.ArgumentNullException">
 269        /// Thrown when a required parameter is null
 270        /// </exception>
 271        /// <return>
 272        /// A response object containing the response body and response headers.
 273        /// </return>
 274        public async Task<AzureOperationResponse<IPage<DirectoryObject>>> GetObjectsByObjectIdsNextWithHttpMessagesAsync
 275        {
 0276            if (nextLink == null)
 277            {
 0278                throw new ValidationException(ValidationRules.CannotBeNull, "nextLink");
 279            }
 0280            if (Client.ApiVersion == null)
 281            {
 0282                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
 283            }
 0284            if (Client.TenantID == null)
 285            {
 0286                throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID");
 287            }
 288            // Tracing
 0289            bool _shouldTrace = ServiceClientTracing.IsEnabled;
 0290            string _invocationId = null;
 0291            if (_shouldTrace)
 292            {
 0293                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
 0294                Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
 0295                tracingParameters.Add("nextLink", nextLink);
 0296                tracingParameters.Add("cancellationToken", cancellationToken);
 0297                ServiceClientTracing.Enter(_invocationId, this, "GetObjectsByObjectIdsNext", tracingParameters);
 298            }
 299            // Construct URL
 0300            var _baseUrl = Client.BaseUri.AbsoluteUri;
 0301            var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/{nextL
 0302            _url = _url.Replace("{nextLink}", nextLink);
 0303            _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID));
 0304            List<string> _queryParameters = new List<string>();
 0305            if (Client.ApiVersion != null)
 306            {
 0307                _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
 308            }
 0309            if (_queryParameters.Count > 0)
 310            {
 0311                _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
 312            }
 313            // Create HTTP transport objects
 0314            var _httpRequest = new HttpRequestMessage();
 0315            HttpResponseMessage _httpResponse = null;
 0316            _httpRequest.Method = new HttpMethod("POST");
 0317            _httpRequest.RequestUri = new System.Uri(_url);
 318            // Set Headers
 0319            if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
 320            {
 0321                _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString())
 322            }
 0323            if (Client.AcceptLanguage != null)
 324            {
 0325                if (_httpRequest.Headers.Contains("accept-language"))
 326                {
 0327                    _httpRequest.Headers.Remove("accept-language");
 328                }
 0329                _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
 330            }
 331
 332
 0333            if (customHeaders != null)
 334            {
 0335                foreach(var _header in customHeaders)
 336                {
 0337                    if (_httpRequest.Headers.Contains(_header.Key))
 338                    {
 0339                        _httpRequest.Headers.Remove(_header.Key);
 340                    }
 0341                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
 342                }
 343            }
 344
 345            // Serialize Request
 0346            string _requestContent = null;
 347            // Set Credentials
 0348            if (Client.Credentials != null)
 349            {
 0350                cancellationToken.ThrowIfCancellationRequested();
 0351                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 352            }
 353            // Send Request
 0354            if (_shouldTrace)
 355            {
 0356                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
 357            }
 0358            cancellationToken.ThrowIfCancellationRequested();
 0359            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
 0360            if (_shouldTrace)
 361            {
 0362                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
 363            }
 0364            HttpStatusCode _statusCode = _httpResponse.StatusCode;
 0365            cancellationToken.ThrowIfCancellationRequested();
 0366            string _responseContent = null;
 0367            if ((int)_statusCode != 200)
 368            {
 0369                var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode
 370                try
 371                {
 0372                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 0373                    CloudError _errorBody =  Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC
 0374                    if (_errorBody != null)
 375                    {
 0376                        ex = new CloudException(_errorBody.Message);
 0377                        ex.Body = _errorBody;
 378                    }
 0379                }
 0380                catch (JsonException)
 381                {
 382                    // Ignore the exception
 0383                }
 0384                ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
 0385                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
 0386                if (_httpResponse.Headers.Contains("x-ms-request-id"))
 387                {
 0388                    ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 389                }
 0390                if (_shouldTrace)
 391                {
 0392                    ServiceClientTracing.Error(_invocationId, ex);
 393                }
 0394                _httpRequest.Dispose();
 0395                if (_httpResponse != null)
 396                {
 0397                    _httpResponse.Dispose();
 398                }
 0399                throw ex;
 400            }
 401            // Create Result
 0402            var _result = new AzureOperationResponse<IPage<DirectoryObject>>();
 0403            _result.Request = _httpRequest;
 0404            _result.Response = _httpResponse;
 0405            if (_httpResponse.Headers.Contains("x-ms-request-id"))
 406            {
 0407                _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
 408            }
 409            // Deserialize Response
 0410            if ((int)_statusCode == 200)
 411            {
 0412                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
 413                try
 414                {
 0415                    _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<DirectoryObject>>(_response
 0416                }
 0417                catch (JsonException ex)
 418                {
 0419                    _httpRequest.Dispose();
 0420                    if (_httpResponse != null)
 421                    {
 0422                        _httpResponse.Dispose();
 423                    }
 0424                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
 425                }
 426            }
 0427            if (_shouldTrace)
 428            {
 0429                ServiceClientTracing.Exit(_invocationId, _result);
 430            }
 0431            return _result;
 0432        }
 433
 434    }
 435}