| | 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.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 | | /// SignedInUserOperations operations. |
| | 27 | | /// </summary> |
| | 28 | | internal partial class SignedInUserOperations : IServiceOperations<GraphRbacManagementClient>, ISignedInUserOperatio |
| | 29 | | { |
| | 30 | | /// <summary> |
| | 31 | | /// Initializes a new instance of the SignedInUserOperations 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> |
| 46 | 39 | | internal SignedInUserOperations(GraphRbacManagementClient client) |
| | 40 | | { |
| 46 | 41 | | if (client == null) |
| | 42 | | { |
| 0 | 43 | | throw new System.ArgumentNullException("client"); |
| | 44 | | } |
| 46 | 45 | | Client = client; |
| 46 | 46 | | } |
| | 47 | |
|
| | 48 | | /// <summary> |
| | 49 | | /// Gets a reference to the GraphRbacManagementClient |
| | 50 | | /// </summary> |
| 0 | 51 | | public GraphRbacManagementClient Client { get; private set; } |
| | 52 | |
|
| | 53 | | /// <summary> |
| | 54 | | /// Gets the details for the currently logged-in user. |
| | 55 | | /// </summary> |
| | 56 | | /// <param name='customHeaders'> |
| | 57 | | /// Headers that will be added to request. |
| | 58 | | /// </param> |
| | 59 | | /// <param name='cancellationToken'> |
| | 60 | | /// The cancellation token. |
| | 61 | | /// </param> |
| | 62 | | /// <exception cref="GraphErrorException"> |
| | 63 | | /// Thrown when the operation returned an invalid status code |
| | 64 | | /// </exception> |
| | 65 | | /// <exception cref="SerializationException"> |
| | 66 | | /// Thrown when unable to deserialize the response |
| | 67 | | /// </exception> |
| | 68 | | /// <exception cref="ValidationException"> |
| | 69 | | /// Thrown when a required parameter is null |
| | 70 | | /// </exception> |
| | 71 | | /// <exception cref="System.ArgumentNullException"> |
| | 72 | | /// Thrown when a required parameter is null |
| | 73 | | /// </exception> |
| | 74 | | /// <return> |
| | 75 | | /// A response object containing the response body and response headers. |
| | 76 | | /// </return> |
| | 77 | | public async Task<AzureOperationResponse<User>> GetWithHttpMessagesAsync(Dictionary<string, List<string>> custom |
| | 78 | | { |
| 0 | 79 | | if (Client.ApiVersion == null) |
| | 80 | | { |
| 0 | 81 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 82 | | } |
| 0 | 83 | | if (Client.TenantID == null) |
| | 84 | | { |
| 0 | 85 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID"); |
| | 86 | | } |
| | 87 | | // Tracing |
| 0 | 88 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 89 | | string _invocationId = null; |
| 0 | 90 | | if (_shouldTrace) |
| | 91 | | { |
| 0 | 92 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 93 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 94 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 95 | | ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); |
| | 96 | | } |
| | 97 | | // Construct URL |
| 0 | 98 | | var _baseUrl = Client.BaseUri.AbsoluteUri; |
| 0 | 99 | | var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/me").T |
| 0 | 100 | | _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID)); |
| 0 | 101 | | List<string> _queryParameters = new List<string>(); |
| 0 | 102 | | if (Client.ApiVersion != null) |
| | 103 | | { |
| 0 | 104 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 105 | | } |
| 0 | 106 | | if (_queryParameters.Count > 0) |
| | 107 | | { |
| 0 | 108 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 109 | | } |
| | 110 | | // Create HTTP transport objects |
| 0 | 111 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 112 | | HttpResponseMessage _httpResponse = null; |
| 0 | 113 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 114 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 115 | | // Set Headers |
| 0 | 116 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 117 | | { |
| 0 | 118 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()) |
| | 119 | | } |
| 0 | 120 | | if (Client.AcceptLanguage != null) |
| | 121 | | { |
| 0 | 122 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 123 | | { |
| 0 | 124 | | _httpRequest.Headers.Remove("accept-language"); |
| | 125 | | } |
| 0 | 126 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 127 | | } |
| | 128 | |
|
| | 129 | |
|
| 0 | 130 | | if (customHeaders != null) |
| | 131 | | { |
| 0 | 132 | | foreach(var _header in customHeaders) |
| | 133 | | { |
| 0 | 134 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 135 | | { |
| 0 | 136 | | _httpRequest.Headers.Remove(_header.Key); |
| | 137 | | } |
| 0 | 138 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 139 | | } |
| | 140 | | } |
| | 141 | |
|
| | 142 | | // Serialize Request |
| 0 | 143 | | string _requestContent = null; |
| | 144 | | // Set Credentials |
| 0 | 145 | | if (Client.Credentials != null) |
| | 146 | | { |
| 0 | 147 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 148 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 149 | | } |
| | 150 | | // Send Request |
| 0 | 151 | | if (_shouldTrace) |
| | 152 | | { |
| 0 | 153 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 154 | | } |
| 0 | 155 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 156 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 157 | | if (_shouldTrace) |
| | 158 | | { |
| 0 | 159 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 160 | | } |
| 0 | 161 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 162 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 163 | | string _responseContent = null; |
| 0 | 164 | | if ((int)_statusCode != 200) |
| | 165 | | { |
| 0 | 166 | | var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 167 | | try |
| | 168 | | { |
| 0 | 169 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 170 | | GraphError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC |
| 0 | 171 | | if (_errorBody != null) |
| | 172 | | { |
| 0 | 173 | | ex.Body = _errorBody; |
| | 174 | | } |
| 0 | 175 | | } |
| 0 | 176 | | catch (JsonException) |
| | 177 | | { |
| | 178 | | // Ignore the exception |
| 0 | 179 | | } |
| 0 | 180 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 181 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 182 | | if (_shouldTrace) |
| | 183 | | { |
| 0 | 184 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 185 | | } |
| 0 | 186 | | _httpRequest.Dispose(); |
| 0 | 187 | | if (_httpResponse != null) |
| | 188 | | { |
| 0 | 189 | | _httpResponse.Dispose(); |
| | 190 | | } |
| 0 | 191 | | throw ex; |
| | 192 | | } |
| | 193 | | // Create Result |
| 0 | 194 | | var _result = new AzureOperationResponse<User>(); |
| 0 | 195 | | _result.Request = _httpRequest; |
| 0 | 196 | | _result.Response = _httpResponse; |
| 0 | 197 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 198 | | { |
| 0 | 199 | | _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 200 | | } |
| | 201 | | // Deserialize Response |
| 0 | 202 | | if ((int)_statusCode == 200) |
| | 203 | | { |
| 0 | 204 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 205 | | try |
| | 206 | | { |
| 0 | 207 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<User>(_responseContent, Client.D |
| 0 | 208 | | } |
| 0 | 209 | | catch (JsonException ex) |
| | 210 | | { |
| 0 | 211 | | _httpRequest.Dispose(); |
| 0 | 212 | | if (_httpResponse != null) |
| | 213 | | { |
| 0 | 214 | | _httpResponse.Dispose(); |
| | 215 | | } |
| 0 | 216 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 217 | | } |
| | 218 | | } |
| 0 | 219 | | if (_shouldTrace) |
| | 220 | | { |
| 0 | 221 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 222 | | } |
| 0 | 223 | | return _result; |
| 0 | 224 | | } |
| | 225 | |
|
| | 226 | | /// <summary> |
| | 227 | | /// Get the list of directory objects that are owned by the user. |
| | 228 | | /// </summary> |
| | 229 | | /// <param name='customHeaders'> |
| | 230 | | /// Headers that will be added to request. |
| | 231 | | /// </param> |
| | 232 | | /// <param name='cancellationToken'> |
| | 233 | | /// The cancellation token. |
| | 234 | | /// </param> |
| | 235 | | /// <exception cref="GraphErrorException"> |
| | 236 | | /// Thrown when the operation returned an invalid status code |
| | 237 | | /// </exception> |
| | 238 | | /// <exception cref="SerializationException"> |
| | 239 | | /// Thrown when unable to deserialize the response |
| | 240 | | /// </exception> |
| | 241 | | /// <exception cref="ValidationException"> |
| | 242 | | /// Thrown when a required parameter is null |
| | 243 | | /// </exception> |
| | 244 | | /// <exception cref="System.ArgumentNullException"> |
| | 245 | | /// Thrown when a required parameter is null |
| | 246 | | /// </exception> |
| | 247 | | /// <return> |
| | 248 | | /// A response object containing the response body and response headers. |
| | 249 | | /// </return> |
| | 250 | | public async Task<AzureOperationResponse<IPage<DirectoryObject>>> ListOwnedObjectsWithHttpMessagesAsync(Dictiona |
| | 251 | | { |
| 0 | 252 | | if (Client.ApiVersion == null) |
| | 253 | | { |
| 0 | 254 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 255 | | } |
| 0 | 256 | | if (Client.TenantID == null) |
| | 257 | | { |
| 0 | 258 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID"); |
| | 259 | | } |
| | 260 | | // Tracing |
| 0 | 261 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 262 | | string _invocationId = null; |
| 0 | 263 | | if (_shouldTrace) |
| | 264 | | { |
| 0 | 265 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 266 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 267 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 268 | | ServiceClientTracing.Enter(_invocationId, this, "ListOwnedObjects", tracingParameters); |
| | 269 | | } |
| | 270 | | // Construct URL |
| 0 | 271 | | var _baseUrl = Client.BaseUri.AbsoluteUri; |
| 0 | 272 | | var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/me/own |
| 0 | 273 | | _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID)); |
| 0 | 274 | | List<string> _queryParameters = new List<string>(); |
| 0 | 275 | | if (Client.ApiVersion != null) |
| | 276 | | { |
| 0 | 277 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 278 | | } |
| 0 | 279 | | if (_queryParameters.Count > 0) |
| | 280 | | { |
| 0 | 281 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 282 | | } |
| | 283 | | // Create HTTP transport objects |
| 0 | 284 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 285 | | HttpResponseMessage _httpResponse = null; |
| 0 | 286 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 287 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 288 | | // Set Headers |
| 0 | 289 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 290 | | { |
| 0 | 291 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()) |
| | 292 | | } |
| 0 | 293 | | if (Client.AcceptLanguage != null) |
| | 294 | | { |
| 0 | 295 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 296 | | { |
| 0 | 297 | | _httpRequest.Headers.Remove("accept-language"); |
| | 298 | | } |
| 0 | 299 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 300 | | } |
| | 301 | |
|
| | 302 | |
|
| 0 | 303 | | if (customHeaders != null) |
| | 304 | | { |
| 0 | 305 | | foreach(var _header in customHeaders) |
| | 306 | | { |
| 0 | 307 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 308 | | { |
| 0 | 309 | | _httpRequest.Headers.Remove(_header.Key); |
| | 310 | | } |
| 0 | 311 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 312 | | } |
| | 313 | | } |
| | 314 | |
|
| | 315 | | // Serialize Request |
| 0 | 316 | | string _requestContent = null; |
| | 317 | | // Set Credentials |
| 0 | 318 | | if (Client.Credentials != null) |
| | 319 | | { |
| 0 | 320 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 321 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 322 | | } |
| | 323 | | // Send Request |
| 0 | 324 | | if (_shouldTrace) |
| | 325 | | { |
| 0 | 326 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 327 | | } |
| 0 | 328 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 329 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 330 | | if (_shouldTrace) |
| | 331 | | { |
| 0 | 332 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 333 | | } |
| 0 | 334 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 335 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 336 | | string _responseContent = null; |
| 0 | 337 | | if ((int)_statusCode != 200) |
| | 338 | | { |
| 0 | 339 | | var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 340 | | try |
| | 341 | | { |
| 0 | 342 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 343 | | GraphError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC |
| 0 | 344 | | if (_errorBody != null) |
| | 345 | | { |
| 0 | 346 | | ex.Body = _errorBody; |
| | 347 | | } |
| 0 | 348 | | } |
| 0 | 349 | | catch (JsonException) |
| | 350 | | { |
| | 351 | | // Ignore the exception |
| 0 | 352 | | } |
| 0 | 353 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 354 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 355 | | if (_shouldTrace) |
| | 356 | | { |
| 0 | 357 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 358 | | } |
| 0 | 359 | | _httpRequest.Dispose(); |
| 0 | 360 | | if (_httpResponse != null) |
| | 361 | | { |
| 0 | 362 | | _httpResponse.Dispose(); |
| | 363 | | } |
| 0 | 364 | | throw ex; |
| | 365 | | } |
| | 366 | | // Create Result |
| 0 | 367 | | var _result = new AzureOperationResponse<IPage<DirectoryObject>>(); |
| 0 | 368 | | _result.Request = _httpRequest; |
| 0 | 369 | | _result.Response = _httpResponse; |
| 0 | 370 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 371 | | { |
| 0 | 372 | | _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 373 | | } |
| | 374 | | // Deserialize Response |
| 0 | 375 | | if ((int)_statusCode == 200) |
| | 376 | | { |
| 0 | 377 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 378 | | try |
| | 379 | | { |
| 0 | 380 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<DirectoryObject>>(_response |
| 0 | 381 | | } |
| 0 | 382 | | catch (JsonException ex) |
| | 383 | | { |
| 0 | 384 | | _httpRequest.Dispose(); |
| 0 | 385 | | if (_httpResponse != null) |
| | 386 | | { |
| 0 | 387 | | _httpResponse.Dispose(); |
| | 388 | | } |
| 0 | 389 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 390 | | } |
| | 391 | | } |
| 0 | 392 | | if (_shouldTrace) |
| | 393 | | { |
| 0 | 394 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 395 | | } |
| 0 | 396 | | return _result; |
| 0 | 397 | | } |
| | 398 | |
|
| | 399 | | /// <summary> |
| | 400 | | /// Get the list of directory objects that are owned by the user. |
| | 401 | | /// </summary> |
| | 402 | | /// <param name='nextLink'> |
| | 403 | | /// Next link for the list operation. |
| | 404 | | /// </param> |
| | 405 | | /// <param name='customHeaders'> |
| | 406 | | /// Headers that will be added to request. |
| | 407 | | /// </param> |
| | 408 | | /// <param name='cancellationToken'> |
| | 409 | | /// The cancellation token. |
| | 410 | | /// </param> |
| | 411 | | /// <exception cref="GraphErrorException"> |
| | 412 | | /// Thrown when the operation returned an invalid status code |
| | 413 | | /// </exception> |
| | 414 | | /// <exception cref="SerializationException"> |
| | 415 | | /// Thrown when unable to deserialize the response |
| | 416 | | /// </exception> |
| | 417 | | /// <exception cref="ValidationException"> |
| | 418 | | /// Thrown when a required parameter is null |
| | 419 | | /// </exception> |
| | 420 | | /// <exception cref="System.ArgumentNullException"> |
| | 421 | | /// Thrown when a required parameter is null |
| | 422 | | /// </exception> |
| | 423 | | /// <return> |
| | 424 | | /// A response object containing the response body and response headers. |
| | 425 | | /// </return> |
| | 426 | | public async Task<AzureOperationResponse<IPage<DirectoryObject>>> ListOwnedObjectsNextWithHttpMessagesAsync(stri |
| | 427 | | { |
| 0 | 428 | | if (nextLink == null) |
| | 429 | | { |
| 0 | 430 | | throw new ValidationException(ValidationRules.CannotBeNull, "nextLink"); |
| | 431 | | } |
| 0 | 432 | | if (Client.ApiVersion == null) |
| | 433 | | { |
| 0 | 434 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 435 | | } |
| 0 | 436 | | if (Client.TenantID == null) |
| | 437 | | { |
| 0 | 438 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID"); |
| | 439 | | } |
| | 440 | | // Tracing |
| 0 | 441 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 442 | | string _invocationId = null; |
| 0 | 443 | | if (_shouldTrace) |
| | 444 | | { |
| 0 | 445 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 446 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 447 | | tracingParameters.Add("nextLink", nextLink); |
| 0 | 448 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 449 | | ServiceClientTracing.Enter(_invocationId, this, "ListOwnedObjectsNext", tracingParameters); |
| | 450 | | } |
| | 451 | | // Construct URL |
| 0 | 452 | | var _baseUrl = Client.BaseUri.AbsoluteUri; |
| 0 | 453 | | var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/{nextL |
| 0 | 454 | | _url = _url.Replace("{nextLink}", nextLink); |
| 0 | 455 | | _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID)); |
| 0 | 456 | | List<string> _queryParameters = new List<string>(); |
| 0 | 457 | | if (Client.ApiVersion != null) |
| | 458 | | { |
| 0 | 459 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 460 | | } |
| 0 | 461 | | if (_queryParameters.Count > 0) |
| | 462 | | { |
| 0 | 463 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 464 | | } |
| | 465 | | // Create HTTP transport objects |
| 0 | 466 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 467 | | HttpResponseMessage _httpResponse = null; |
| 0 | 468 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 469 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 470 | | // Set Headers |
| 0 | 471 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 472 | | { |
| 0 | 473 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()) |
| | 474 | | } |
| 0 | 475 | | if (Client.AcceptLanguage != null) |
| | 476 | | { |
| 0 | 477 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 478 | | { |
| 0 | 479 | | _httpRequest.Headers.Remove("accept-language"); |
| | 480 | | } |
| 0 | 481 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 482 | | } |
| | 483 | |
|
| | 484 | |
|
| 0 | 485 | | if (customHeaders != null) |
| | 486 | | { |
| 0 | 487 | | foreach(var _header in customHeaders) |
| | 488 | | { |
| 0 | 489 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 490 | | { |
| 0 | 491 | | _httpRequest.Headers.Remove(_header.Key); |
| | 492 | | } |
| 0 | 493 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 494 | | } |
| | 495 | | } |
| | 496 | |
|
| | 497 | | // Serialize Request |
| 0 | 498 | | string _requestContent = null; |
| | 499 | | // Set Credentials |
| 0 | 500 | | if (Client.Credentials != null) |
| | 501 | | { |
| 0 | 502 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 503 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 504 | | } |
| | 505 | | // Send Request |
| 0 | 506 | | if (_shouldTrace) |
| | 507 | | { |
| 0 | 508 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 509 | | } |
| 0 | 510 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 511 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 512 | | if (_shouldTrace) |
| | 513 | | { |
| 0 | 514 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 515 | | } |
| 0 | 516 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 517 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 518 | | string _responseContent = null; |
| 0 | 519 | | if ((int)_statusCode != 200) |
| | 520 | | { |
| 0 | 521 | | var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 522 | | try |
| | 523 | | { |
| 0 | 524 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 525 | | GraphError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC |
| 0 | 526 | | if (_errorBody != null) |
| | 527 | | { |
| 0 | 528 | | ex.Body = _errorBody; |
| | 529 | | } |
| 0 | 530 | | } |
| 0 | 531 | | catch (JsonException) |
| | 532 | | { |
| | 533 | | // Ignore the exception |
| 0 | 534 | | } |
| 0 | 535 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 536 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 537 | | if (_shouldTrace) |
| | 538 | | { |
| 0 | 539 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 540 | | } |
| 0 | 541 | | _httpRequest.Dispose(); |
| 0 | 542 | | if (_httpResponse != null) |
| | 543 | | { |
| 0 | 544 | | _httpResponse.Dispose(); |
| | 545 | | } |
| 0 | 546 | | throw ex; |
| | 547 | | } |
| | 548 | | // Create Result |
| 0 | 549 | | var _result = new AzureOperationResponse<IPage<DirectoryObject>>(); |
| 0 | 550 | | _result.Request = _httpRequest; |
| 0 | 551 | | _result.Response = _httpResponse; |
| 0 | 552 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 553 | | { |
| 0 | 554 | | _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 555 | | } |
| | 556 | | // Deserialize Response |
| 0 | 557 | | if ((int)_statusCode == 200) |
| | 558 | | { |
| 0 | 559 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 560 | | try |
| | 561 | | { |
| 0 | 562 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<DirectoryObject>>(_response |
| 0 | 563 | | } |
| 0 | 564 | | catch (JsonException ex) |
| | 565 | | { |
| 0 | 566 | | _httpRequest.Dispose(); |
| 0 | 567 | | if (_httpResponse != null) |
| | 568 | | { |
| 0 | 569 | | _httpResponse.Dispose(); |
| | 570 | | } |
| 0 | 571 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 572 | | } |
| | 573 | | } |
| 0 | 574 | | if (_shouldTrace) |
| | 575 | | { |
| 0 | 576 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 577 | | } |
| 0 | 578 | | return _result; |
| 0 | 579 | | } |
| | 580 | |
|
| | 581 | | } |
| | 582 | | } |