| | 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 | | /// 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> |
| 46 | 39 | | internal ObjectsOperations(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> |
| 136 | 51 | | 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 | | { |
| 6 | 84 | | if (parameters == null) |
| | 85 | | { |
| 0 | 86 | | throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); |
| | 87 | | } |
| 6 | 88 | | if (Client.ApiVersion == null) |
| | 89 | | { |
| 0 | 90 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 91 | | } |
| 6 | 92 | | if (Client.TenantID == null) |
| | 93 | | { |
| 0 | 94 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID"); |
| | 95 | | } |
| | 96 | | // Tracing |
| 6 | 97 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 6 | 98 | | string _invocationId = null; |
| 6 | 99 | | if (_shouldTrace) |
| | 100 | | { |
| 0 | 101 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 102 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 103 | | tracingParameters.Add("parameters", parameters); |
| 0 | 104 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 105 | | ServiceClientTracing.Enter(_invocationId, this, "GetObjectsByObjectIds", tracingParameters); |
| | 106 | | } |
| | 107 | | // Construct URL |
| 6 | 108 | | var _baseUrl = Client.BaseUri.AbsoluteUri; |
| 6 | 109 | | var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/getObj |
| 6 | 110 | | _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID)); |
| 6 | 111 | | List<string> _queryParameters = new List<string>(); |
| 6 | 112 | | if (Client.ApiVersion != null) |
| | 113 | | { |
| 6 | 114 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 115 | | } |
| 6 | 116 | | if (_queryParameters.Count > 0) |
| | 117 | | { |
| 6 | 118 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 119 | | } |
| | 120 | | // Create HTTP transport objects |
| 6 | 121 | | var _httpRequest = new HttpRequestMessage(); |
| 6 | 122 | | HttpResponseMessage _httpResponse = null; |
| 6 | 123 | | _httpRequest.Method = new HttpMethod("POST"); |
| 6 | 124 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 125 | | // Set Headers |
| 6 | 126 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 127 | | { |
| 6 | 128 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()) |
| | 129 | | } |
| 6 | 130 | | if (Client.AcceptLanguage != null) |
| | 131 | | { |
| 6 | 132 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 133 | | { |
| 0 | 134 | | _httpRequest.Headers.Remove("accept-language"); |
| | 135 | | } |
| 6 | 136 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 137 | | } |
| | 138 | |
|
| | 139 | |
|
| 6 | 140 | | if (customHeaders != null) |
| | 141 | | { |
| 0 | 142 | | foreach(var _header in customHeaders) |
| | 143 | | { |
| 0 | 144 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 145 | | { |
| 0 | 146 | | _httpRequest.Headers.Remove(_header.Key); |
| | 147 | | } |
| 0 | 148 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 149 | | } |
| | 150 | | } |
| | 151 | |
|
| | 152 | | // Serialize Request |
| 6 | 153 | | string _requestContent = null; |
| 6 | 154 | | if(parameters != null) |
| | 155 | | { |
| 6 | 156 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSet |
| 6 | 157 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 6 | 158 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 159 | | } |
| | 160 | | // Set Credentials |
| 6 | 161 | | if (Client.Credentials != null) |
| | 162 | | { |
| 6 | 163 | | cancellationToken.ThrowIfCancellationRequested(); |
| 6 | 164 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 165 | | } |
| | 166 | | // Send Request |
| 6 | 167 | | if (_shouldTrace) |
| | 168 | | { |
| 0 | 169 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 170 | | } |
| 6 | 171 | | cancellationToken.ThrowIfCancellationRequested(); |
| 6 | 172 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 6 | 173 | | if (_shouldTrace) |
| | 174 | | { |
| 0 | 175 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 176 | | } |
| 6 | 177 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 6 | 178 | | cancellationToken.ThrowIfCancellationRequested(); |
| 6 | 179 | | string _responseContent = null; |
| 6 | 180 | | if ((int)_statusCode != 200) |
| | 181 | | { |
| 0 | 182 | | var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode |
| | 183 | | try |
| | 184 | | { |
| 0 | 185 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 186 | | CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC |
| 0 | 187 | | if (_errorBody != null) |
| | 188 | | { |
| 0 | 189 | | ex = new CloudException(_errorBody.Message); |
| 0 | 190 | | ex.Body = _errorBody; |
| | 191 | | } |
| 0 | 192 | | } |
| 0 | 193 | | catch (JsonException) |
| | 194 | | { |
| | 195 | | // Ignore the exception |
| 0 | 196 | | } |
| 0 | 197 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 198 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 199 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 200 | | { |
| 0 | 201 | | ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 202 | | } |
| 0 | 203 | | if (_shouldTrace) |
| | 204 | | { |
| 0 | 205 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 206 | | } |
| 0 | 207 | | _httpRequest.Dispose(); |
| 0 | 208 | | if (_httpResponse != null) |
| | 209 | | { |
| 0 | 210 | | _httpResponse.Dispose(); |
| | 211 | | } |
| 0 | 212 | | throw ex; |
| | 213 | | } |
| | 214 | | // Create Result |
| 6 | 215 | | var _result = new AzureOperationResponse<IPage<DirectoryObject>>(); |
| 6 | 216 | | _result.Request = _httpRequest; |
| 6 | 217 | | _result.Response = _httpResponse; |
| 6 | 218 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 219 | | { |
| 0 | 220 | | _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 221 | | } |
| | 222 | | // Deserialize Response |
| 6 | 223 | | if ((int)_statusCode == 200) |
| | 224 | | { |
| 6 | 225 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 226 | | try |
| | 227 | | { |
| 6 | 228 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<DirectoryObject>>(_response |
| 6 | 229 | | } |
| 0 | 230 | | catch (JsonException ex) |
| | 231 | | { |
| 0 | 232 | | _httpRequest.Dispose(); |
| 0 | 233 | | if (_httpResponse != null) |
| | 234 | | { |
| 0 | 235 | | _httpResponse.Dispose(); |
| | 236 | | } |
| 0 | 237 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 238 | | } |
| | 239 | | } |
| 6 | 240 | | if (_shouldTrace) |
| | 241 | | { |
| 0 | 242 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 243 | | } |
| 6 | 244 | | return _result; |
| 6 | 245 | | } |
| | 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 | | { |
| 0 | 276 | | if (nextLink == null) |
| | 277 | | { |
| 0 | 278 | | throw new ValidationException(ValidationRules.CannotBeNull, "nextLink"); |
| | 279 | | } |
| 0 | 280 | | if (Client.ApiVersion == null) |
| | 281 | | { |
| 0 | 282 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 283 | | } |
| 0 | 284 | | if (Client.TenantID == null) |
| | 285 | | { |
| 0 | 286 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID"); |
| | 287 | | } |
| | 288 | | // Tracing |
| 0 | 289 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 290 | | string _invocationId = null; |
| 0 | 291 | | if (_shouldTrace) |
| | 292 | | { |
| 0 | 293 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 294 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 295 | | tracingParameters.Add("nextLink", nextLink); |
| 0 | 296 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 297 | | ServiceClientTracing.Enter(_invocationId, this, "GetObjectsByObjectIdsNext", tracingParameters); |
| | 298 | | } |
| | 299 | | // Construct URL |
| 0 | 300 | | var _baseUrl = Client.BaseUri.AbsoluteUri; |
| 0 | 301 | | var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/{nextL |
| 0 | 302 | | _url = _url.Replace("{nextLink}", nextLink); |
| 0 | 303 | | _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID)); |
| 0 | 304 | | List<string> _queryParameters = new List<string>(); |
| 0 | 305 | | if (Client.ApiVersion != null) |
| | 306 | | { |
| 0 | 307 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 308 | | } |
| 0 | 309 | | if (_queryParameters.Count > 0) |
| | 310 | | { |
| 0 | 311 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 312 | | } |
| | 313 | | // Create HTTP transport objects |
| 0 | 314 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 315 | | HttpResponseMessage _httpResponse = null; |
| 0 | 316 | | _httpRequest.Method = new HttpMethod("POST"); |
| 0 | 317 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 318 | | // Set Headers |
| 0 | 319 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 320 | | { |
| 0 | 321 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()) |
| | 322 | | } |
| 0 | 323 | | if (Client.AcceptLanguage != null) |
| | 324 | | { |
| 0 | 325 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 326 | | { |
| 0 | 327 | | _httpRequest.Headers.Remove("accept-language"); |
| | 328 | | } |
| 0 | 329 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 330 | | } |
| | 331 | |
|
| | 332 | |
|
| 0 | 333 | | if (customHeaders != null) |
| | 334 | | { |
| 0 | 335 | | foreach(var _header in customHeaders) |
| | 336 | | { |
| 0 | 337 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 338 | | { |
| 0 | 339 | | _httpRequest.Headers.Remove(_header.Key); |
| | 340 | | } |
| 0 | 341 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 342 | | } |
| | 343 | | } |
| | 344 | |
|
| | 345 | | // Serialize Request |
| 0 | 346 | | string _requestContent = null; |
| | 347 | | // Set Credentials |
| 0 | 348 | | if (Client.Credentials != null) |
| | 349 | | { |
| 0 | 350 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 351 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 352 | | } |
| | 353 | | // Send Request |
| 0 | 354 | | if (_shouldTrace) |
| | 355 | | { |
| 0 | 356 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 357 | | } |
| 0 | 358 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 359 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 360 | | if (_shouldTrace) |
| | 361 | | { |
| 0 | 362 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 363 | | } |
| 0 | 364 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 365 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 366 | | string _responseContent = null; |
| 0 | 367 | | if ((int)_statusCode != 200) |
| | 368 | | { |
| 0 | 369 | | var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode |
| | 370 | | try |
| | 371 | | { |
| 0 | 372 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 373 | | CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseC |
| 0 | 374 | | if (_errorBody != null) |
| | 375 | | { |
| 0 | 376 | | ex = new CloudException(_errorBody.Message); |
| 0 | 377 | | ex.Body = _errorBody; |
| | 378 | | } |
| 0 | 379 | | } |
| 0 | 380 | | catch (JsonException) |
| | 381 | | { |
| | 382 | | // Ignore the exception |
| 0 | 383 | | } |
| 0 | 384 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 385 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 386 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 387 | | { |
| 0 | 388 | | ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 389 | | } |
| 0 | 390 | | if (_shouldTrace) |
| | 391 | | { |
| 0 | 392 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 393 | | } |
| 0 | 394 | | _httpRequest.Dispose(); |
| 0 | 395 | | if (_httpResponse != null) |
| | 396 | | { |
| 0 | 397 | | _httpResponse.Dispose(); |
| | 398 | | } |
| 0 | 399 | | throw ex; |
| | 400 | | } |
| | 401 | | // Create Result |
| 0 | 402 | | var _result = new AzureOperationResponse<IPage<DirectoryObject>>(); |
| 0 | 403 | | _result.Request = _httpRequest; |
| 0 | 404 | | _result.Response = _httpResponse; |
| 0 | 405 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 406 | | { |
| 0 | 407 | | _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 408 | | } |
| | 409 | | // Deserialize Response |
| 0 | 410 | | if ((int)_statusCode == 200) |
| | 411 | | { |
| 0 | 412 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 413 | | try |
| | 414 | | { |
| 0 | 415 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<DirectoryObject>>(_response |
| 0 | 416 | | } |
| 0 | 417 | | catch (JsonException ex) |
| | 418 | | { |
| 0 | 419 | | _httpRequest.Dispose(); |
| 0 | 420 | | if (_httpResponse != null) |
| | 421 | | { |
| 0 | 422 | | _httpResponse.Dispose(); |
| | 423 | | } |
| 0 | 424 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 425 | | } |
| | 426 | | } |
| 0 | 427 | | if (_shouldTrace) |
| | 428 | | { |
| 0 | 429 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 430 | | } |
| 0 | 431 | | return _result; |
| 0 | 432 | | } |
| | 433 | |
|
| | 434 | | } |
| | 435 | | } |