| | 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 | | /// DeletedApplicationsOperations operations. |
| | 27 | | /// </summary> |
| | 28 | | internal partial class DeletedApplicationsOperations : IServiceOperations<GraphRbacManagementClient>, IDeletedApplic |
| | 29 | | { |
| | 30 | | /// <summary> |
| | 31 | | /// Initializes a new instance of the DeletedApplicationsOperations 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 DeletedApplicationsOperations(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 | | /// Restores the deleted application in the directory. |
| | 55 | | /// </summary> |
| | 56 | | /// <param name='objectId'> |
| | 57 | | /// Application object ID. |
| | 58 | | /// </param> |
| | 59 | | /// <param name='customHeaders'> |
| | 60 | | /// Headers that will be added to request. |
| | 61 | | /// </param> |
| | 62 | | /// <param name='cancellationToken'> |
| | 63 | | /// The cancellation token. |
| | 64 | | /// </param> |
| | 65 | | /// <exception cref="GraphErrorException"> |
| | 66 | | /// Thrown when the operation returned an invalid status code |
| | 67 | | /// </exception> |
| | 68 | | /// <exception cref="SerializationException"> |
| | 69 | | /// Thrown when unable to deserialize the response |
| | 70 | | /// </exception> |
| | 71 | | /// <exception cref="ValidationException"> |
| | 72 | | /// Thrown when a required parameter is null |
| | 73 | | /// </exception> |
| | 74 | | /// <exception cref="System.ArgumentNullException"> |
| | 75 | | /// Thrown when a required parameter is null |
| | 76 | | /// </exception> |
| | 77 | | /// <return> |
| | 78 | | /// A response object containing the response body and response headers. |
| | 79 | | /// </return> |
| | 80 | | public async Task<AzureOperationResponse<Application>> RestoreWithHttpMessagesAsync(string objectId, Dictionary< |
| | 81 | | { |
| 0 | 82 | | if (objectId == null) |
| | 83 | | { |
| 0 | 84 | | throw new ValidationException(ValidationRules.CannotBeNull, "objectId"); |
| | 85 | | } |
| 0 | 86 | | if (Client.ApiVersion == null) |
| | 87 | | { |
| 0 | 88 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 89 | | } |
| 0 | 90 | | if (Client.TenantID == null) |
| | 91 | | { |
| 0 | 92 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID"); |
| | 93 | | } |
| | 94 | | // Tracing |
| 0 | 95 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 96 | | string _invocationId = null; |
| 0 | 97 | | if (_shouldTrace) |
| | 98 | | { |
| 0 | 99 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 100 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 101 | | tracingParameters.Add("objectId", objectId); |
| 0 | 102 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 103 | | ServiceClientTracing.Enter(_invocationId, this, "Restore", tracingParameters); |
| | 104 | | } |
| | 105 | | // Construct URL |
| 0 | 106 | | var _baseUrl = Client.BaseUri.AbsoluteUri; |
| 0 | 107 | | var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/delete |
| 0 | 108 | | _url = _url.Replace("{objectId}", System.Uri.EscapeDataString(objectId)); |
| 0 | 109 | | _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID)); |
| 0 | 110 | | List<string> _queryParameters = new List<string>(); |
| 0 | 111 | | if (Client.ApiVersion != null) |
| | 112 | | { |
| 0 | 113 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 114 | | } |
| 0 | 115 | | if (_queryParameters.Count > 0) |
| | 116 | | { |
| 0 | 117 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 118 | | } |
| | 119 | | // Create HTTP transport objects |
| 0 | 120 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 121 | | HttpResponseMessage _httpResponse = null; |
| 0 | 122 | | _httpRequest.Method = new HttpMethod("POST"); |
| 0 | 123 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 124 | | // Set Headers |
| 0 | 125 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 126 | | { |
| 0 | 127 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()) |
| | 128 | | } |
| 0 | 129 | | if (Client.AcceptLanguage != null) |
| | 130 | | { |
| 0 | 131 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 132 | | { |
| 0 | 133 | | _httpRequest.Headers.Remove("accept-language"); |
| | 134 | | } |
| 0 | 135 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 136 | | } |
| | 137 | |
|
| | 138 | |
|
| 0 | 139 | | if (customHeaders != null) |
| | 140 | | { |
| 0 | 141 | | foreach(var _header in customHeaders) |
| | 142 | | { |
| 0 | 143 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 144 | | { |
| 0 | 145 | | _httpRequest.Headers.Remove(_header.Key); |
| | 146 | | } |
| 0 | 147 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 148 | | } |
| | 149 | | } |
| | 150 | |
|
| | 151 | | // Serialize Request |
| 0 | 152 | | string _requestContent = null; |
| | 153 | | // Set Credentials |
| 0 | 154 | | if (Client.Credentials != null) |
| | 155 | | { |
| 0 | 156 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 157 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 158 | | } |
| | 159 | | // Send Request |
| 0 | 160 | | if (_shouldTrace) |
| | 161 | | { |
| 0 | 162 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 163 | | } |
| 0 | 164 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 165 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 166 | | if (_shouldTrace) |
| | 167 | | { |
| 0 | 168 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 169 | | } |
| 0 | 170 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 171 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 172 | | string _responseContent = null; |
| 0 | 173 | | if ((int)_statusCode != 200) |
| | 174 | | { |
| 0 | 175 | | var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 176 | | try |
| | 177 | | { |
| 0 | 178 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 179 | | GraphError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC |
| 0 | 180 | | if (_errorBody != null) |
| | 181 | | { |
| 0 | 182 | | ex.Body = _errorBody; |
| | 183 | | } |
| 0 | 184 | | } |
| 0 | 185 | | catch (JsonException) |
| | 186 | | { |
| | 187 | | // Ignore the exception |
| 0 | 188 | | } |
| 0 | 189 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 190 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 191 | | if (_shouldTrace) |
| | 192 | | { |
| 0 | 193 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 194 | | } |
| 0 | 195 | | _httpRequest.Dispose(); |
| 0 | 196 | | if (_httpResponse != null) |
| | 197 | | { |
| 0 | 198 | | _httpResponse.Dispose(); |
| | 199 | | } |
| 0 | 200 | | throw ex; |
| | 201 | | } |
| | 202 | | // Create Result |
| 0 | 203 | | var _result = new AzureOperationResponse<Application>(); |
| 0 | 204 | | _result.Request = _httpRequest; |
| 0 | 205 | | _result.Response = _httpResponse; |
| 0 | 206 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 207 | | { |
| 0 | 208 | | _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 209 | | } |
| | 210 | | // Deserialize Response |
| 0 | 211 | | if ((int)_statusCode == 200) |
| | 212 | | { |
| 0 | 213 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 214 | | try |
| | 215 | | { |
| 0 | 216 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Application>(_responseContent, C |
| 0 | 217 | | } |
| 0 | 218 | | catch (JsonException ex) |
| | 219 | | { |
| 0 | 220 | | _httpRequest.Dispose(); |
| 0 | 221 | | if (_httpResponse != null) |
| | 222 | | { |
| 0 | 223 | | _httpResponse.Dispose(); |
| | 224 | | } |
| 0 | 225 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 226 | | } |
| | 227 | | } |
| 0 | 228 | | if (_shouldTrace) |
| | 229 | | { |
| 0 | 230 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 231 | | } |
| 0 | 232 | | return _result; |
| 0 | 233 | | } |
| | 234 | |
|
| | 235 | | /// <summary> |
| | 236 | | /// Gets a list of deleted applications in the directory. |
| | 237 | | /// </summary> |
| | 238 | | /// <param name='filter'> |
| | 239 | | /// The filter to apply to the operation. |
| | 240 | | /// </param> |
| | 241 | | /// <param name='customHeaders'> |
| | 242 | | /// Headers that will be added to request. |
| | 243 | | /// </param> |
| | 244 | | /// <param name='cancellationToken'> |
| | 245 | | /// The cancellation token. |
| | 246 | | /// </param> |
| | 247 | | /// <exception cref="GraphErrorException"> |
| | 248 | | /// Thrown when the operation returned an invalid status code |
| | 249 | | /// </exception> |
| | 250 | | /// <exception cref="SerializationException"> |
| | 251 | | /// Thrown when unable to deserialize the response |
| | 252 | | /// </exception> |
| | 253 | | /// <exception cref="ValidationException"> |
| | 254 | | /// Thrown when a required parameter is null |
| | 255 | | /// </exception> |
| | 256 | | /// <exception cref="System.ArgumentNullException"> |
| | 257 | | /// Thrown when a required parameter is null |
| | 258 | | /// </exception> |
| | 259 | | /// <return> |
| | 260 | | /// A response object containing the response body and response headers. |
| | 261 | | /// </return> |
| | 262 | | public async Task<AzureOperationResponse<IPage<Application>>> ListWithHttpMessagesAsync(string filter = default( |
| | 263 | | { |
| 0 | 264 | | if (Client.ApiVersion == null) |
| | 265 | | { |
| 0 | 266 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 267 | | } |
| 0 | 268 | | if (Client.TenantID == null) |
| | 269 | | { |
| 0 | 270 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID"); |
| | 271 | | } |
| | 272 | | // Tracing |
| 0 | 273 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 274 | | string _invocationId = null; |
| 0 | 275 | | if (_shouldTrace) |
| | 276 | | { |
| 0 | 277 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 278 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 279 | | tracingParameters.Add("filter", filter); |
| 0 | 280 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 281 | | ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); |
| | 282 | | } |
| | 283 | | // Construct URL |
| 0 | 284 | | var _baseUrl = Client.BaseUri.AbsoluteUri; |
| 0 | 285 | | var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/delete |
| 0 | 286 | | _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID)); |
| 0 | 287 | | List<string> _queryParameters = new List<string>(); |
| 0 | 288 | | if (filter != null) |
| | 289 | | { |
| 0 | 290 | | _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); |
| | 291 | | } |
| 0 | 292 | | if (Client.ApiVersion != null) |
| | 293 | | { |
| 0 | 294 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 295 | | } |
| 0 | 296 | | if (_queryParameters.Count > 0) |
| | 297 | | { |
| 0 | 298 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 299 | | } |
| | 300 | | // Create HTTP transport objects |
| 0 | 301 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 302 | | HttpResponseMessage _httpResponse = null; |
| 0 | 303 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 304 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 305 | | // Set Headers |
| 0 | 306 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 307 | | { |
| 0 | 308 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()) |
| | 309 | | } |
| 0 | 310 | | if (Client.AcceptLanguage != null) |
| | 311 | | { |
| 0 | 312 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 313 | | { |
| 0 | 314 | | _httpRequest.Headers.Remove("accept-language"); |
| | 315 | | } |
| 0 | 316 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 317 | | } |
| | 318 | |
|
| | 319 | |
|
| 0 | 320 | | if (customHeaders != null) |
| | 321 | | { |
| 0 | 322 | | foreach(var _header in customHeaders) |
| | 323 | | { |
| 0 | 324 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 325 | | { |
| 0 | 326 | | _httpRequest.Headers.Remove(_header.Key); |
| | 327 | | } |
| 0 | 328 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 329 | | } |
| | 330 | | } |
| | 331 | |
|
| | 332 | | // Serialize Request |
| 0 | 333 | | string _requestContent = null; |
| | 334 | | // Set Credentials |
| 0 | 335 | | if (Client.Credentials != null) |
| | 336 | | { |
| 0 | 337 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 338 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 339 | | } |
| | 340 | | // Send Request |
| 0 | 341 | | if (_shouldTrace) |
| | 342 | | { |
| 0 | 343 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 344 | | } |
| 0 | 345 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 346 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 347 | | if (_shouldTrace) |
| | 348 | | { |
| 0 | 349 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 350 | | } |
| 0 | 351 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 352 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 353 | | string _responseContent = null; |
| 0 | 354 | | if ((int)_statusCode != 200) |
| | 355 | | { |
| 0 | 356 | | var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 357 | | try |
| | 358 | | { |
| 0 | 359 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 360 | | GraphError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC |
| 0 | 361 | | if (_errorBody != null) |
| | 362 | | { |
| 0 | 363 | | ex.Body = _errorBody; |
| | 364 | | } |
| 0 | 365 | | } |
| 0 | 366 | | catch (JsonException) |
| | 367 | | { |
| | 368 | | // Ignore the exception |
| 0 | 369 | | } |
| 0 | 370 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 371 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 372 | | if (_shouldTrace) |
| | 373 | | { |
| 0 | 374 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 375 | | } |
| 0 | 376 | | _httpRequest.Dispose(); |
| 0 | 377 | | if (_httpResponse != null) |
| | 378 | | { |
| 0 | 379 | | _httpResponse.Dispose(); |
| | 380 | | } |
| 0 | 381 | | throw ex; |
| | 382 | | } |
| | 383 | | // Create Result |
| 0 | 384 | | var _result = new AzureOperationResponse<IPage<Application>>(); |
| 0 | 385 | | _result.Request = _httpRequest; |
| 0 | 386 | | _result.Response = _httpResponse; |
| 0 | 387 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 388 | | { |
| 0 | 389 | | _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 390 | | } |
| | 391 | | // Deserialize Response |
| 0 | 392 | | if ((int)_statusCode == 200) |
| | 393 | | { |
| 0 | 394 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 395 | | try |
| | 396 | | { |
| 0 | 397 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<Application>>(_responseCont |
| 0 | 398 | | } |
| 0 | 399 | | catch (JsonException ex) |
| | 400 | | { |
| 0 | 401 | | _httpRequest.Dispose(); |
| 0 | 402 | | if (_httpResponse != null) |
| | 403 | | { |
| 0 | 404 | | _httpResponse.Dispose(); |
| | 405 | | } |
| 0 | 406 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 407 | | } |
| | 408 | | } |
| 0 | 409 | | if (_shouldTrace) |
| | 410 | | { |
| 0 | 411 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 412 | | } |
| 0 | 413 | | return _result; |
| 0 | 414 | | } |
| | 415 | |
|
| | 416 | | /// <summary> |
| | 417 | | /// Hard-delete an application. |
| | 418 | | /// </summary> |
| | 419 | | /// <param name='applicationObjectId'> |
| | 420 | | /// Application object ID. |
| | 421 | | /// </param> |
| | 422 | | /// <param name='customHeaders'> |
| | 423 | | /// Headers that will be added to request. |
| | 424 | | /// </param> |
| | 425 | | /// <param name='cancellationToken'> |
| | 426 | | /// The cancellation token. |
| | 427 | | /// </param> |
| | 428 | | /// <exception cref="GraphErrorException"> |
| | 429 | | /// Thrown when the operation returned an invalid status code |
| | 430 | | /// </exception> |
| | 431 | | /// <exception cref="ValidationException"> |
| | 432 | | /// Thrown when a required parameter is null |
| | 433 | | /// </exception> |
| | 434 | | /// <exception cref="System.ArgumentNullException"> |
| | 435 | | /// Thrown when a required parameter is null |
| | 436 | | /// </exception> |
| | 437 | | /// <return> |
| | 438 | | /// A response object containing the response body and response headers. |
| | 439 | | /// </return> |
| | 440 | | public async Task<AzureOperationResponse> HardDeleteWithHttpMessagesAsync(string applicationObjectId, Dictionary |
| | 441 | | { |
| 0 | 442 | | if (applicationObjectId == null) |
| | 443 | | { |
| 0 | 444 | | throw new ValidationException(ValidationRules.CannotBeNull, "applicationObjectId"); |
| | 445 | | } |
| 0 | 446 | | if (Client.ApiVersion == null) |
| | 447 | | { |
| 0 | 448 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 449 | | } |
| 0 | 450 | | if (Client.TenantID == null) |
| | 451 | | { |
| 0 | 452 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID"); |
| | 453 | | } |
| | 454 | | // Tracing |
| 0 | 455 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 456 | | string _invocationId = null; |
| 0 | 457 | | if (_shouldTrace) |
| | 458 | | { |
| 0 | 459 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 460 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 461 | | tracingParameters.Add("applicationObjectId", applicationObjectId); |
| 0 | 462 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 463 | | ServiceClientTracing.Enter(_invocationId, this, "HardDelete", tracingParameters); |
| | 464 | | } |
| | 465 | | // Construct URL |
| 0 | 466 | | var _baseUrl = Client.BaseUri.AbsoluteUri; |
| 0 | 467 | | var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/delete |
| 0 | 468 | | _url = _url.Replace("{applicationObjectId}", System.Uri.EscapeDataString(applicationObjectId)); |
| 0 | 469 | | _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID)); |
| 0 | 470 | | List<string> _queryParameters = new List<string>(); |
| 0 | 471 | | if (Client.ApiVersion != null) |
| | 472 | | { |
| 0 | 473 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 474 | | } |
| 0 | 475 | | if (_queryParameters.Count > 0) |
| | 476 | | { |
| 0 | 477 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 478 | | } |
| | 479 | | // Create HTTP transport objects |
| 0 | 480 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 481 | | HttpResponseMessage _httpResponse = null; |
| 0 | 482 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 0 | 483 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 484 | | // Set Headers |
| 0 | 485 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 486 | | { |
| 0 | 487 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()) |
| | 488 | | } |
| 0 | 489 | | if (Client.AcceptLanguage != null) |
| | 490 | | { |
| 0 | 491 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 492 | | { |
| 0 | 493 | | _httpRequest.Headers.Remove("accept-language"); |
| | 494 | | } |
| 0 | 495 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 496 | | } |
| | 497 | |
|
| | 498 | |
|
| 0 | 499 | | if (customHeaders != null) |
| | 500 | | { |
| 0 | 501 | | foreach(var _header in customHeaders) |
| | 502 | | { |
| 0 | 503 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 504 | | { |
| 0 | 505 | | _httpRequest.Headers.Remove(_header.Key); |
| | 506 | | } |
| 0 | 507 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 508 | | } |
| | 509 | | } |
| | 510 | |
|
| | 511 | | // Serialize Request |
| 0 | 512 | | string _requestContent = null; |
| | 513 | | // Set Credentials |
| 0 | 514 | | if (Client.Credentials != null) |
| | 515 | | { |
| 0 | 516 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 517 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 518 | | } |
| | 519 | | // Send Request |
| 0 | 520 | | if (_shouldTrace) |
| | 521 | | { |
| 0 | 522 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 523 | | } |
| 0 | 524 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 525 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 526 | | if (_shouldTrace) |
| | 527 | | { |
| 0 | 528 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 529 | | } |
| 0 | 530 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 531 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 532 | | string _responseContent = null; |
| 0 | 533 | | if ((int)_statusCode != 204) |
| | 534 | | { |
| 0 | 535 | | var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 536 | | try |
| | 537 | | { |
| 0 | 538 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 539 | | GraphError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC |
| 0 | 540 | | if (_errorBody != null) |
| | 541 | | { |
| 0 | 542 | | ex.Body = _errorBody; |
| | 543 | | } |
| 0 | 544 | | } |
| 0 | 545 | | catch (JsonException) |
| | 546 | | { |
| | 547 | | // Ignore the exception |
| 0 | 548 | | } |
| 0 | 549 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 550 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 551 | | if (_shouldTrace) |
| | 552 | | { |
| 0 | 553 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 554 | | } |
| 0 | 555 | | _httpRequest.Dispose(); |
| 0 | 556 | | if (_httpResponse != null) |
| | 557 | | { |
| 0 | 558 | | _httpResponse.Dispose(); |
| | 559 | | } |
| 0 | 560 | | throw ex; |
| | 561 | | } |
| | 562 | | // Create Result |
| 0 | 563 | | var _result = new AzureOperationResponse(); |
| 0 | 564 | | _result.Request = _httpRequest; |
| 0 | 565 | | _result.Response = _httpResponse; |
| 0 | 566 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 567 | | { |
| 0 | 568 | | _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 569 | | } |
| 0 | 570 | | if (_shouldTrace) |
| | 571 | | { |
| 0 | 572 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 573 | | } |
| 0 | 574 | | return _result; |
| 0 | 575 | | } |
| | 576 | |
|
| | 577 | | /// <summary> |
| | 578 | | /// Gets a list of deleted applications in the directory. |
| | 579 | | /// </summary> |
| | 580 | | /// <param name='nextLink'> |
| | 581 | | /// Next link for the list operation. |
| | 582 | | /// </param> |
| | 583 | | /// <param name='customHeaders'> |
| | 584 | | /// Headers that will be added to request. |
| | 585 | | /// </param> |
| | 586 | | /// <param name='cancellationToken'> |
| | 587 | | /// The cancellation token. |
| | 588 | | /// </param> |
| | 589 | | /// <exception cref="GraphErrorException"> |
| | 590 | | /// Thrown when the operation returned an invalid status code |
| | 591 | | /// </exception> |
| | 592 | | /// <exception cref="SerializationException"> |
| | 593 | | /// Thrown when unable to deserialize the response |
| | 594 | | /// </exception> |
| | 595 | | /// <exception cref="ValidationException"> |
| | 596 | | /// Thrown when a required parameter is null |
| | 597 | | /// </exception> |
| | 598 | | /// <exception cref="System.ArgumentNullException"> |
| | 599 | | /// Thrown when a required parameter is null |
| | 600 | | /// </exception> |
| | 601 | | /// <return> |
| | 602 | | /// A response object containing the response body and response headers. |
| | 603 | | /// </return> |
| | 604 | | public async Task<AzureOperationResponse<IPage<Application>>> ListNextWithHttpMessagesAsync(string nextLink, Dic |
| | 605 | | { |
| 0 | 606 | | if (nextLink == null) |
| | 607 | | { |
| 0 | 608 | | throw new ValidationException(ValidationRules.CannotBeNull, "nextLink"); |
| | 609 | | } |
| 0 | 610 | | if (Client.ApiVersion == null) |
| | 611 | | { |
| 0 | 612 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); |
| | 613 | | } |
| 0 | 614 | | if (Client.TenantID == null) |
| | 615 | | { |
| 0 | 616 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.TenantID"); |
| | 617 | | } |
| | 618 | | // Tracing |
| 0 | 619 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 620 | | string _invocationId = null; |
| 0 | 621 | | if (_shouldTrace) |
| | 622 | | { |
| 0 | 623 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 624 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 625 | | tracingParameters.Add("nextLink", nextLink); |
| 0 | 626 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 627 | | ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); |
| | 628 | | } |
| | 629 | | // Construct URL |
| 0 | 630 | | var _baseUrl = Client.BaseUri.AbsoluteUri; |
| 0 | 631 | | var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{tenantID}/{nextL |
| 0 | 632 | | _url = _url.Replace("{nextLink}", nextLink); |
| 0 | 633 | | _url = _url.Replace("{tenantID}", System.Uri.EscapeDataString(Client.TenantID)); |
| 0 | 634 | | List<string> _queryParameters = new List<string>(); |
| 0 | 635 | | if (Client.ApiVersion != null) |
| | 636 | | { |
| 0 | 637 | | _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); |
| | 638 | | } |
| 0 | 639 | | if (_queryParameters.Count > 0) |
| | 640 | | { |
| 0 | 641 | | _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); |
| | 642 | | } |
| | 643 | | // Create HTTP transport objects |
| 0 | 644 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 645 | | HttpResponseMessage _httpResponse = null; |
| 0 | 646 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 647 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 648 | | // Set Headers |
| 0 | 649 | | if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) |
| | 650 | | { |
| 0 | 651 | | _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()) |
| | 652 | | } |
| 0 | 653 | | if (Client.AcceptLanguage != null) |
| | 654 | | { |
| 0 | 655 | | if (_httpRequest.Headers.Contains("accept-language")) |
| | 656 | | { |
| 0 | 657 | | _httpRequest.Headers.Remove("accept-language"); |
| | 658 | | } |
| 0 | 659 | | _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); |
| | 660 | | } |
| | 661 | |
|
| | 662 | |
|
| 0 | 663 | | if (customHeaders != null) |
| | 664 | | { |
| 0 | 665 | | foreach(var _header in customHeaders) |
| | 666 | | { |
| 0 | 667 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 668 | | { |
| 0 | 669 | | _httpRequest.Headers.Remove(_header.Key); |
| | 670 | | } |
| 0 | 671 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 672 | | } |
| | 673 | | } |
| | 674 | |
|
| | 675 | | // Serialize Request |
| 0 | 676 | | string _requestContent = null; |
| | 677 | | // Set Credentials |
| 0 | 678 | | if (Client.Credentials != null) |
| | 679 | | { |
| 0 | 680 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 681 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 682 | | } |
| | 683 | | // Send Request |
| 0 | 684 | | if (_shouldTrace) |
| | 685 | | { |
| 0 | 686 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 687 | | } |
| 0 | 688 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 689 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 690 | | if (_shouldTrace) |
| | 691 | | { |
| 0 | 692 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 693 | | } |
| 0 | 694 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 695 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 696 | | string _responseContent = null; |
| 0 | 697 | | if ((int)_statusCode != 200) |
| | 698 | | { |
| 0 | 699 | | var ex = new GraphErrorException(string.Format("Operation returned an invalid status code '{0}'", _statu |
| | 700 | | try |
| | 701 | | { |
| 0 | 702 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 703 | | GraphError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<GraphError>(_responseC |
| 0 | 704 | | if (_errorBody != null) |
| | 705 | | { |
| 0 | 706 | | ex.Body = _errorBody; |
| | 707 | | } |
| 0 | 708 | | } |
| 0 | 709 | | catch (JsonException) |
| | 710 | | { |
| | 711 | | // Ignore the exception |
| 0 | 712 | | } |
| 0 | 713 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 714 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 715 | | if (_shouldTrace) |
| | 716 | | { |
| 0 | 717 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 718 | | } |
| 0 | 719 | | _httpRequest.Dispose(); |
| 0 | 720 | | if (_httpResponse != null) |
| | 721 | | { |
| 0 | 722 | | _httpResponse.Dispose(); |
| | 723 | | } |
| 0 | 724 | | throw ex; |
| | 725 | | } |
| | 726 | | // Create Result |
| 0 | 727 | | var _result = new AzureOperationResponse<IPage<Application>>(); |
| 0 | 728 | | _result.Request = _httpRequest; |
| 0 | 729 | | _result.Response = _httpResponse; |
| 0 | 730 | | if (_httpResponse.Headers.Contains("x-ms-request-id")) |
| | 731 | | { |
| 0 | 732 | | _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); |
| | 733 | | } |
| | 734 | | // Deserialize Response |
| 0 | 735 | | if ((int)_statusCode == 200) |
| | 736 | | { |
| 0 | 737 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 738 | | try |
| | 739 | | { |
| 0 | 740 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<Page<Application>>(_responseCont |
| 0 | 741 | | } |
| 0 | 742 | | catch (JsonException ex) |
| | 743 | | { |
| 0 | 744 | | _httpRequest.Dispose(); |
| 0 | 745 | | if (_httpResponse != null) |
| | 746 | | { |
| 0 | 747 | | _httpResponse.Dispose(); |
| | 748 | | } |
| 0 | 749 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 750 | | } |
| | 751 | | } |
| 0 | 752 | | if (_shouldTrace) |
| | 753 | | { |
| 0 | 754 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 755 | | } |
| 0 | 756 | | return _result; |
| 0 | 757 | | } |
| | 758 | |
|
| | 759 | | } |
| | 760 | | } |