| | 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.CognitiveServices.Language.LUIS.Authoring |
| | 12 | | { |
| | 13 | | using Microsoft.Rest; |
| | 14 | | using Models; |
| | 15 | | using Newtonsoft.Json; |
| | 16 | | using System.Collections; |
| | 17 | | using System.Collections.Generic; |
| | 18 | | using System.IO; |
| | 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 | | /// Model operations. |
| | 27 | | /// </summary> |
| | 28 | | public partial class Model : IServiceOperations<LUISAuthoringClient>, IModel |
| | 29 | | { |
| | 30 | | /// <summary> |
| | 31 | | /// Initializes a new instance of the Model 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> |
| 156 | 39 | | public Model(LUISAuthoringClient client) |
| | 40 | | { |
| 156 | 41 | | if (client == null) |
| | 42 | | { |
| 0 | 43 | | throw new System.ArgumentNullException("client"); |
| | 44 | | } |
| 156 | 45 | | Client = client; |
| 156 | 46 | | } |
| | 47 | |
|
| | 48 | | /// <summary> |
| | 49 | | /// Gets a reference to the LUISAuthoringClient |
| | 50 | | /// </summary> |
| 3702 | 51 | | public LUISAuthoringClient Client { get; private set; } |
| | 52 | |
|
| | 53 | | /// <summary> |
| | 54 | | /// Adds an intent to a version of the application. |
| | 55 | | /// </summary> |
| | 56 | | /// <param name='appId'> |
| | 57 | | /// The application ID. |
| | 58 | | /// </param> |
| | 59 | | /// <param name='versionId'> |
| | 60 | | /// The version ID. |
| | 61 | | /// </param> |
| | 62 | | /// <param name='intentCreateObject'> |
| | 63 | | /// A model object containing the name of the new intent. |
| | 64 | | /// </param> |
| | 65 | | /// <param name='customHeaders'> |
| | 66 | | /// Headers that will be added to request. |
| | 67 | | /// </param> |
| | 68 | | /// <param name='cancellationToken'> |
| | 69 | | /// The cancellation token. |
| | 70 | | /// </param> |
| | 71 | | /// <exception cref="ErrorResponseException"> |
| | 72 | | /// Thrown when the operation returned an invalid status code |
| | 73 | | /// </exception> |
| | 74 | | /// <exception cref="SerializationException"> |
| | 75 | | /// Thrown when unable to deserialize the response |
| | 76 | | /// </exception> |
| | 77 | | /// <exception cref="ValidationException"> |
| | 78 | | /// Thrown when a required parameter is null |
| | 79 | | /// </exception> |
| | 80 | | /// <exception cref="System.ArgumentNullException"> |
| | 81 | | /// Thrown when a required parameter is null |
| | 82 | | /// </exception> |
| | 83 | | /// <return> |
| | 84 | | /// A response object containing the response body and response headers. |
| | 85 | | /// </return> |
| | 86 | | public async Task<HttpOperationResponse<System.Guid>> AddIntentWithHttpMessagesAsync(System.Guid appId, string v |
| | 87 | | { |
| 12 | 88 | | if (Client.Endpoint == null) |
| | 89 | | { |
| 0 | 90 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 91 | | } |
| 12 | 92 | | if (versionId == null) |
| | 93 | | { |
| 0 | 94 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 95 | | } |
| 12 | 96 | | if (intentCreateObject == null) |
| | 97 | | { |
| 0 | 98 | | throw new ValidationException(ValidationRules.CannotBeNull, "intentCreateObject"); |
| | 99 | | } |
| | 100 | | // Tracing |
| 12 | 101 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 12 | 102 | | string _invocationId = null; |
| 12 | 103 | | if (_shouldTrace) |
| | 104 | | { |
| 0 | 105 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 106 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 107 | | tracingParameters.Add("appId", appId); |
| 0 | 108 | | tracingParameters.Add("versionId", versionId); |
| 0 | 109 | | tracingParameters.Add("intentCreateObject", intentCreateObject); |
| 0 | 110 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 111 | | ServiceClientTracing.Enter(_invocationId, this, "AddIntent", tracingParameters); |
| | 112 | | } |
| | 113 | | // Construct URL |
| 12 | 114 | | var _baseUrl = Client.BaseUri; |
| 12 | 115 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents"; |
| 12 | 116 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 12 | 117 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 12 | 118 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| | 119 | | // Create HTTP transport objects |
| 12 | 120 | | var _httpRequest = new HttpRequestMessage(); |
| 12 | 121 | | HttpResponseMessage _httpResponse = null; |
| 12 | 122 | | _httpRequest.Method = new HttpMethod("POST"); |
| 12 | 123 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 124 | | // Set Headers |
| | 125 | |
|
| | 126 | |
|
| 12 | 127 | | if (customHeaders != null) |
| | 128 | | { |
| 0 | 129 | | foreach(var _header in customHeaders) |
| | 130 | | { |
| 0 | 131 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 132 | | { |
| 0 | 133 | | _httpRequest.Headers.Remove(_header.Key); |
| | 134 | | } |
| 0 | 135 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 136 | | } |
| | 137 | | } |
| | 138 | |
|
| | 139 | | // Serialize Request |
| 12 | 140 | | string _requestContent = null; |
| 12 | 141 | | if(intentCreateObject != null) |
| | 142 | | { |
| 12 | 143 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(intentCreateObject, Client.Serializ |
| 12 | 144 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 12 | 145 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 146 | | } |
| | 147 | | // Set Credentials |
| 12 | 148 | | if (Client.Credentials != null) |
| | 149 | | { |
| 12 | 150 | | cancellationToken.ThrowIfCancellationRequested(); |
| 12 | 151 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 152 | | } |
| | 153 | | // Send Request |
| 12 | 154 | | if (_shouldTrace) |
| | 155 | | { |
| 0 | 156 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 157 | | } |
| 12 | 158 | | cancellationToken.ThrowIfCancellationRequested(); |
| 12 | 159 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 12 | 160 | | if (_shouldTrace) |
| | 161 | | { |
| 0 | 162 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 163 | | } |
| 12 | 164 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 12 | 165 | | cancellationToken.ThrowIfCancellationRequested(); |
| 12 | 166 | | string _responseContent = null; |
| 12 | 167 | | if ((int)_statusCode != 201) |
| | 168 | | { |
| 0 | 169 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 170 | | try |
| | 171 | | { |
| 0 | 172 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 173 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 174 | | if (_errorBody != null) |
| | 175 | | { |
| 0 | 176 | | ex.Body = _errorBody; |
| | 177 | | } |
| 0 | 178 | | } |
| 0 | 179 | | catch (JsonException) |
| | 180 | | { |
| | 181 | | // Ignore the exception |
| 0 | 182 | | } |
| 0 | 183 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 184 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 185 | | if (_shouldTrace) |
| | 186 | | { |
| 0 | 187 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 188 | | } |
| 0 | 189 | | _httpRequest.Dispose(); |
| 0 | 190 | | if (_httpResponse != null) |
| | 191 | | { |
| 0 | 192 | | _httpResponse.Dispose(); |
| | 193 | | } |
| 0 | 194 | | throw ex; |
| | 195 | | } |
| | 196 | | // Create Result |
| 12 | 197 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 12 | 198 | | _result.Request = _httpRequest; |
| 12 | 199 | | _result.Response = _httpResponse; |
| | 200 | | // Deserialize Response |
| 12 | 201 | | if ((int)_statusCode == 201) |
| | 202 | | { |
| 12 | 203 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 204 | | try |
| | 205 | | { |
| 12 | 206 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 12 | 207 | | } |
| 0 | 208 | | catch (JsonException ex) |
| | 209 | | { |
| 0 | 210 | | _httpRequest.Dispose(); |
| 0 | 211 | | if (_httpResponse != null) |
| | 212 | | { |
| 0 | 213 | | _httpResponse.Dispose(); |
| | 214 | | } |
| 0 | 215 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 216 | | } |
| | 217 | | } |
| 12 | 218 | | if (_shouldTrace) |
| | 219 | | { |
| 0 | 220 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 221 | | } |
| 12 | 222 | | return _result; |
| 12 | 223 | | } |
| | 224 | |
|
| | 225 | | /// <summary> |
| | 226 | | /// Gets information about the intent models in a version of the application. |
| | 227 | | /// </summary> |
| | 228 | | /// <param name='appId'> |
| | 229 | | /// The application ID. |
| | 230 | | /// </param> |
| | 231 | | /// <param name='versionId'> |
| | 232 | | /// The version ID. |
| | 233 | | /// </param> |
| | 234 | | /// <param name='skip'> |
| | 235 | | /// The number of entries to skip. Default value is 0. |
| | 236 | | /// </param> |
| | 237 | | /// <param name='take'> |
| | 238 | | /// The number of entries to return. Maximum page size is 500. Default is 100. |
| | 239 | | /// </param> |
| | 240 | | /// <param name='customHeaders'> |
| | 241 | | /// Headers that will be added to request. |
| | 242 | | /// </param> |
| | 243 | | /// <param name='cancellationToken'> |
| | 244 | | /// The cancellation token. |
| | 245 | | /// </param> |
| | 246 | | /// <exception cref="ErrorResponseException"> |
| | 247 | | /// Thrown when the operation returned an invalid status code |
| | 248 | | /// </exception> |
| | 249 | | /// <exception cref="SerializationException"> |
| | 250 | | /// Thrown when unable to deserialize the response |
| | 251 | | /// </exception> |
| | 252 | | /// <exception cref="ValidationException"> |
| | 253 | | /// Thrown when a required parameter is null |
| | 254 | | /// </exception> |
| | 255 | | /// <exception cref="System.ArgumentNullException"> |
| | 256 | | /// Thrown when a required parameter is null |
| | 257 | | /// </exception> |
| | 258 | | /// <return> |
| | 259 | | /// A response object containing the response body and response headers. |
| | 260 | | /// </return> |
| | 261 | | public async Task<HttpOperationResponse<IList<IntentClassifier>>> ListIntentsWithHttpMessagesAsync(System.Guid a |
| | 262 | | { |
| 4 | 263 | | if (Client.Endpoint == null) |
| | 264 | | { |
| 0 | 265 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 266 | | } |
| 4 | 267 | | if (versionId == null) |
| | 268 | | { |
| 0 | 269 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 270 | | } |
| 4 | 271 | | if (skip < 0) |
| | 272 | | { |
| 0 | 273 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0); |
| | 274 | | } |
| 4 | 275 | | if (take > 500) |
| | 276 | | { |
| 0 | 277 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500); |
| | 278 | | } |
| 4 | 279 | | if (take < 0) |
| | 280 | | { |
| 0 | 281 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0); |
| | 282 | | } |
| | 283 | | // Tracing |
| 4 | 284 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 4 | 285 | | string _invocationId = null; |
| 4 | 286 | | if (_shouldTrace) |
| | 287 | | { |
| 0 | 288 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 289 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 290 | | tracingParameters.Add("appId", appId); |
| 0 | 291 | | tracingParameters.Add("versionId", versionId); |
| 0 | 292 | | tracingParameters.Add("skip", skip); |
| 0 | 293 | | tracingParameters.Add("take", take); |
| 0 | 294 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 295 | | ServiceClientTracing.Enter(_invocationId, this, "ListIntents", tracingParameters); |
| | 296 | | } |
| | 297 | | // Construct URL |
| 4 | 298 | | var _baseUrl = Client.BaseUri; |
| 4 | 299 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents"; |
| 4 | 300 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 4 | 301 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 4 | 302 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 4 | 303 | | List<string> _queryParameters = new List<string>(); |
| 4 | 304 | | if (skip != null) |
| | 305 | | { |
| 4 | 306 | | _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 307 | | } |
| 4 | 308 | | if (take != null) |
| | 309 | | { |
| 4 | 310 | | _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 311 | | } |
| 4 | 312 | | if (_queryParameters.Count > 0) |
| | 313 | | { |
| 4 | 314 | | _url += "?" + string.Join("&", _queryParameters); |
| | 315 | | } |
| | 316 | | // Create HTTP transport objects |
| 4 | 317 | | var _httpRequest = new HttpRequestMessage(); |
| 4 | 318 | | HttpResponseMessage _httpResponse = null; |
| 4 | 319 | | _httpRequest.Method = new HttpMethod("GET"); |
| 4 | 320 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 321 | | // Set Headers |
| | 322 | |
|
| | 323 | |
|
| 4 | 324 | | if (customHeaders != null) |
| | 325 | | { |
| 0 | 326 | | foreach(var _header in customHeaders) |
| | 327 | | { |
| 0 | 328 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 329 | | { |
| 0 | 330 | | _httpRequest.Headers.Remove(_header.Key); |
| | 331 | | } |
| 0 | 332 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 333 | | } |
| | 334 | | } |
| | 335 | |
|
| | 336 | | // Serialize Request |
| 4 | 337 | | string _requestContent = null; |
| | 338 | | // Set Credentials |
| 4 | 339 | | if (Client.Credentials != null) |
| | 340 | | { |
| 4 | 341 | | cancellationToken.ThrowIfCancellationRequested(); |
| 4 | 342 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 343 | | } |
| | 344 | | // Send Request |
| 4 | 345 | | if (_shouldTrace) |
| | 346 | | { |
| 0 | 347 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 348 | | } |
| 4 | 349 | | cancellationToken.ThrowIfCancellationRequested(); |
| 4 | 350 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 4 | 351 | | if (_shouldTrace) |
| | 352 | | { |
| 0 | 353 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 354 | | } |
| 4 | 355 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 4 | 356 | | cancellationToken.ThrowIfCancellationRequested(); |
| 4 | 357 | | string _responseContent = null; |
| 4 | 358 | | if ((int)_statusCode != 200) |
| | 359 | | { |
| 0 | 360 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 361 | | try |
| | 362 | | { |
| 0 | 363 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 364 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 365 | | if (_errorBody != null) |
| | 366 | | { |
| 0 | 367 | | ex.Body = _errorBody; |
| | 368 | | } |
| 0 | 369 | | } |
| 0 | 370 | | catch (JsonException) |
| | 371 | | { |
| | 372 | | // Ignore the exception |
| 0 | 373 | | } |
| 0 | 374 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 375 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 376 | | if (_shouldTrace) |
| | 377 | | { |
| 0 | 378 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 379 | | } |
| 0 | 380 | | _httpRequest.Dispose(); |
| 0 | 381 | | if (_httpResponse != null) |
| | 382 | | { |
| 0 | 383 | | _httpResponse.Dispose(); |
| | 384 | | } |
| 0 | 385 | | throw ex; |
| | 386 | | } |
| | 387 | | // Create Result |
| 4 | 388 | | var _result = new HttpOperationResponse<IList<IntentClassifier>>(); |
| 4 | 389 | | _result.Request = _httpRequest; |
| 4 | 390 | | _result.Response = _httpResponse; |
| | 391 | | // Deserialize Response |
| 4 | 392 | | if ((int)_statusCode == 200) |
| | 393 | | { |
| 4 | 394 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 395 | | try |
| | 396 | | { |
| 4 | 397 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<IntentClassifier>>(_respon |
| 4 | 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 | | } |
| 4 | 409 | | if (_shouldTrace) |
| | 410 | | { |
| 0 | 411 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 412 | | } |
| 4 | 413 | | return _result; |
| 4 | 414 | | } |
| | 415 | |
|
| | 416 | | /// <summary> |
| | 417 | | /// Adds an entity extractor to a version of the application. |
| | 418 | | /// </summary> |
| | 419 | | /// <param name='appId'> |
| | 420 | | /// The application ID. |
| | 421 | | /// </param> |
| | 422 | | /// <param name='versionId'> |
| | 423 | | /// The version ID. |
| | 424 | | /// </param> |
| | 425 | | /// <param name='entityModelCreateObject'> |
| | 426 | | /// A model object containing the name of the new entity extractor and its |
| | 427 | | /// children. |
| | 428 | | /// </param> |
| | 429 | | /// <param name='customHeaders'> |
| | 430 | | /// Headers that will be added to request. |
| | 431 | | /// </param> |
| | 432 | | /// <param name='cancellationToken'> |
| | 433 | | /// The cancellation token. |
| | 434 | | /// </param> |
| | 435 | | /// <exception cref="ErrorResponseException"> |
| | 436 | | /// Thrown when the operation returned an invalid status code |
| | 437 | | /// </exception> |
| | 438 | | /// <exception cref="SerializationException"> |
| | 439 | | /// Thrown when unable to deserialize the response |
| | 440 | | /// </exception> |
| | 441 | | /// <exception cref="ValidationException"> |
| | 442 | | /// Thrown when a required parameter is null |
| | 443 | | /// </exception> |
| | 444 | | /// <exception cref="System.ArgumentNullException"> |
| | 445 | | /// Thrown when a required parameter is null |
| | 446 | | /// </exception> |
| | 447 | | /// <return> |
| | 448 | | /// A response object containing the response body and response headers. |
| | 449 | | /// </return> |
| | 450 | | public async Task<HttpOperationResponse<System.Guid>> AddEntityWithHttpMessagesAsync(System.Guid appId, string v |
| | 451 | | { |
| 33 | 452 | | if (Client.Endpoint == null) |
| | 453 | | { |
| 0 | 454 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 455 | | } |
| 33 | 456 | | if (versionId == null) |
| | 457 | | { |
| 0 | 458 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 459 | | } |
| 33 | 460 | | if (entityModelCreateObject == null) |
| | 461 | | { |
| 0 | 462 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityModelCreateObject"); |
| | 463 | | } |
| | 464 | | // Tracing |
| 33 | 465 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 33 | 466 | | string _invocationId = null; |
| 33 | 467 | | if (_shouldTrace) |
| | 468 | | { |
| 0 | 469 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 470 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 471 | | tracingParameters.Add("appId", appId); |
| 0 | 472 | | tracingParameters.Add("versionId", versionId); |
| 0 | 473 | | tracingParameters.Add("entityModelCreateObject", entityModelCreateObject); |
| 0 | 474 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 475 | | ServiceClientTracing.Enter(_invocationId, this, "AddEntity", tracingParameters); |
| | 476 | | } |
| | 477 | | // Construct URL |
| 33 | 478 | | var _baseUrl = Client.BaseUri; |
| 33 | 479 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities"; |
| 33 | 480 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 33 | 481 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 33 | 482 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| | 483 | | // Create HTTP transport objects |
| 33 | 484 | | var _httpRequest = new HttpRequestMessage(); |
| 33 | 485 | | HttpResponseMessage _httpResponse = null; |
| 33 | 486 | | _httpRequest.Method = new HttpMethod("POST"); |
| 33 | 487 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 488 | | // Set Headers |
| | 489 | |
|
| | 490 | |
|
| 33 | 491 | | if (customHeaders != null) |
| | 492 | | { |
| 0 | 493 | | foreach(var _header in customHeaders) |
| | 494 | | { |
| 0 | 495 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 496 | | { |
| 0 | 497 | | _httpRequest.Headers.Remove(_header.Key); |
| | 498 | | } |
| 0 | 499 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 500 | | } |
| | 501 | | } |
| | 502 | |
|
| | 503 | | // Serialize Request |
| 33 | 504 | | string _requestContent = null; |
| 33 | 505 | | if(entityModelCreateObject != null) |
| | 506 | | { |
| 33 | 507 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityModelCreateObject, Client.Ser |
| 33 | 508 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 33 | 509 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 510 | | } |
| | 511 | | // Set Credentials |
| 33 | 512 | | if (Client.Credentials != null) |
| | 513 | | { |
| 33 | 514 | | cancellationToken.ThrowIfCancellationRequested(); |
| 33 | 515 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 516 | | } |
| | 517 | | // Send Request |
| 33 | 518 | | if (_shouldTrace) |
| | 519 | | { |
| 0 | 520 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 521 | | } |
| 33 | 522 | | cancellationToken.ThrowIfCancellationRequested(); |
| 33 | 523 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 33 | 524 | | if (_shouldTrace) |
| | 525 | | { |
| 0 | 526 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 527 | | } |
| 33 | 528 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 33 | 529 | | cancellationToken.ThrowIfCancellationRequested(); |
| 33 | 530 | | string _responseContent = null; |
| 33 | 531 | | if ((int)_statusCode != 201) |
| | 532 | | { |
| 0 | 533 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 534 | | try |
| | 535 | | { |
| 0 | 536 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 537 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 538 | | if (_errorBody != null) |
| | 539 | | { |
| 0 | 540 | | ex.Body = _errorBody; |
| | 541 | | } |
| 0 | 542 | | } |
| 0 | 543 | | catch (JsonException) |
| | 544 | | { |
| | 545 | | // Ignore the exception |
| 0 | 546 | | } |
| 0 | 547 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 548 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 549 | | if (_shouldTrace) |
| | 550 | | { |
| 0 | 551 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 552 | | } |
| 0 | 553 | | _httpRequest.Dispose(); |
| 0 | 554 | | if (_httpResponse != null) |
| | 555 | | { |
| 0 | 556 | | _httpResponse.Dispose(); |
| | 557 | | } |
| 0 | 558 | | throw ex; |
| | 559 | | } |
| | 560 | | // Create Result |
| 33 | 561 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 33 | 562 | | _result.Request = _httpRequest; |
| 33 | 563 | | _result.Response = _httpResponse; |
| | 564 | | // Deserialize Response |
| 33 | 565 | | if ((int)_statusCode == 201) |
| | 566 | | { |
| 33 | 567 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 568 | | try |
| | 569 | | { |
| 33 | 570 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 33 | 571 | | } |
| 0 | 572 | | catch (JsonException ex) |
| | 573 | | { |
| 0 | 574 | | _httpRequest.Dispose(); |
| 0 | 575 | | if (_httpResponse != null) |
| | 576 | | { |
| 0 | 577 | | _httpResponse.Dispose(); |
| | 578 | | } |
| 0 | 579 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 580 | | } |
| | 581 | | } |
| 33 | 582 | | if (_shouldTrace) |
| | 583 | | { |
| 0 | 584 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 585 | | } |
| 33 | 586 | | return _result; |
| 33 | 587 | | } |
| | 588 | |
|
| | 589 | | /// <summary> |
| | 590 | | /// Gets information about all the simple entity models in a version of the |
| | 591 | | /// application. |
| | 592 | | /// </summary> |
| | 593 | | /// <param name='appId'> |
| | 594 | | /// The application ID. |
| | 595 | | /// </param> |
| | 596 | | /// <param name='versionId'> |
| | 597 | | /// The version ID. |
| | 598 | | /// </param> |
| | 599 | | /// <param name='skip'> |
| | 600 | | /// The number of entries to skip. Default value is 0. |
| | 601 | | /// </param> |
| | 602 | | /// <param name='take'> |
| | 603 | | /// The number of entries to return. Maximum page size is 500. Default is 100. |
| | 604 | | /// </param> |
| | 605 | | /// <param name='customHeaders'> |
| | 606 | | /// Headers that will be added to request. |
| | 607 | | /// </param> |
| | 608 | | /// <param name='cancellationToken'> |
| | 609 | | /// The cancellation token. |
| | 610 | | /// </param> |
| | 611 | | /// <exception cref="ErrorResponseException"> |
| | 612 | | /// Thrown when the operation returned an invalid status code |
| | 613 | | /// </exception> |
| | 614 | | /// <exception cref="SerializationException"> |
| | 615 | | /// Thrown when unable to deserialize the response |
| | 616 | | /// </exception> |
| | 617 | | /// <exception cref="ValidationException"> |
| | 618 | | /// Thrown when a required parameter is null |
| | 619 | | /// </exception> |
| | 620 | | /// <exception cref="System.ArgumentNullException"> |
| | 621 | | /// Thrown when a required parameter is null |
| | 622 | | /// </exception> |
| | 623 | | /// <return> |
| | 624 | | /// A response object containing the response body and response headers. |
| | 625 | | /// </return> |
| | 626 | | public async Task<HttpOperationResponse<IList<NDepthEntityExtractor>>> ListEntitiesWithHttpMessagesAsync(System. |
| | 627 | | { |
| 3 | 628 | | if (Client.Endpoint == null) |
| | 629 | | { |
| 0 | 630 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 631 | | } |
| 3 | 632 | | if (versionId == null) |
| | 633 | | { |
| 0 | 634 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 635 | | } |
| 3 | 636 | | if (skip < 0) |
| | 637 | | { |
| 0 | 638 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0); |
| | 639 | | } |
| 3 | 640 | | if (take > 500) |
| | 641 | | { |
| 0 | 642 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500); |
| | 643 | | } |
| 3 | 644 | | if (take < 0) |
| | 645 | | { |
| 0 | 646 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0); |
| | 647 | | } |
| | 648 | | // Tracing |
| 3 | 649 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 3 | 650 | | string _invocationId = null; |
| 3 | 651 | | if (_shouldTrace) |
| | 652 | | { |
| 0 | 653 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 654 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 655 | | tracingParameters.Add("appId", appId); |
| 0 | 656 | | tracingParameters.Add("versionId", versionId); |
| 0 | 657 | | tracingParameters.Add("skip", skip); |
| 0 | 658 | | tracingParameters.Add("take", take); |
| 0 | 659 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 660 | | ServiceClientTracing.Enter(_invocationId, this, "ListEntities", tracingParameters); |
| | 661 | | } |
| | 662 | | // Construct URL |
| 3 | 663 | | var _baseUrl = Client.BaseUri; |
| 3 | 664 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities"; |
| 3 | 665 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 3 | 666 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 3 | 667 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 3 | 668 | | List<string> _queryParameters = new List<string>(); |
| 3 | 669 | | if (skip != null) |
| | 670 | | { |
| 3 | 671 | | _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 672 | | } |
| 3 | 673 | | if (take != null) |
| | 674 | | { |
| 3 | 675 | | _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 676 | | } |
| 3 | 677 | | if (_queryParameters.Count > 0) |
| | 678 | | { |
| 3 | 679 | | _url += "?" + string.Join("&", _queryParameters); |
| | 680 | | } |
| | 681 | | // Create HTTP transport objects |
| 3 | 682 | | var _httpRequest = new HttpRequestMessage(); |
| 3 | 683 | | HttpResponseMessage _httpResponse = null; |
| 3 | 684 | | _httpRequest.Method = new HttpMethod("GET"); |
| 3 | 685 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 686 | | // Set Headers |
| | 687 | |
|
| | 688 | |
|
| 3 | 689 | | if (customHeaders != null) |
| | 690 | | { |
| 0 | 691 | | foreach(var _header in customHeaders) |
| | 692 | | { |
| 0 | 693 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 694 | | { |
| 0 | 695 | | _httpRequest.Headers.Remove(_header.Key); |
| | 696 | | } |
| 0 | 697 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 698 | | } |
| | 699 | | } |
| | 700 | |
|
| | 701 | | // Serialize Request |
| 3 | 702 | | string _requestContent = null; |
| | 703 | | // Set Credentials |
| 3 | 704 | | if (Client.Credentials != null) |
| | 705 | | { |
| 3 | 706 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 707 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 708 | | } |
| | 709 | | // Send Request |
| 3 | 710 | | if (_shouldTrace) |
| | 711 | | { |
| 0 | 712 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 713 | | } |
| 3 | 714 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 715 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 3 | 716 | | if (_shouldTrace) |
| | 717 | | { |
| 0 | 718 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 719 | | } |
| 3 | 720 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 3 | 721 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 722 | | string _responseContent = null; |
| 3 | 723 | | if ((int)_statusCode != 200) |
| | 724 | | { |
| 0 | 725 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 726 | | try |
| | 727 | | { |
| 0 | 728 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 729 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 730 | | if (_errorBody != null) |
| | 731 | | { |
| 0 | 732 | | ex.Body = _errorBody; |
| | 733 | | } |
| 0 | 734 | | } |
| 0 | 735 | | catch (JsonException) |
| | 736 | | { |
| | 737 | | // Ignore the exception |
| 0 | 738 | | } |
| 0 | 739 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 740 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 741 | | if (_shouldTrace) |
| | 742 | | { |
| 0 | 743 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 744 | | } |
| 0 | 745 | | _httpRequest.Dispose(); |
| 0 | 746 | | if (_httpResponse != null) |
| | 747 | | { |
| 0 | 748 | | _httpResponse.Dispose(); |
| | 749 | | } |
| 0 | 750 | | throw ex; |
| | 751 | | } |
| | 752 | | // Create Result |
| 3 | 753 | | var _result = new HttpOperationResponse<IList<NDepthEntityExtractor>>(); |
| 3 | 754 | | _result.Request = _httpRequest; |
| 3 | 755 | | _result.Response = _httpResponse; |
| | 756 | | // Deserialize Response |
| 3 | 757 | | if ((int)_statusCode == 200) |
| | 758 | | { |
| 3 | 759 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 760 | | try |
| | 761 | | { |
| 3 | 762 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<NDepthEntityExtractor>>(_r |
| 3 | 763 | | } |
| 0 | 764 | | catch (JsonException ex) |
| | 765 | | { |
| 0 | 766 | | _httpRequest.Dispose(); |
| 0 | 767 | | if (_httpResponse != null) |
| | 768 | | { |
| 0 | 769 | | _httpResponse.Dispose(); |
| | 770 | | } |
| 0 | 771 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 772 | | } |
| | 773 | | } |
| 3 | 774 | | if (_shouldTrace) |
| | 775 | | { |
| 0 | 776 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 777 | | } |
| 3 | 778 | | return _result; |
| 3 | 779 | | } |
| | 780 | |
|
| | 781 | | /// <summary> |
| | 782 | | /// Gets information about all the hierarchical entity models in a version of |
| | 783 | | /// the application. |
| | 784 | | /// </summary> |
| | 785 | | /// <param name='appId'> |
| | 786 | | /// The application ID. |
| | 787 | | /// </param> |
| | 788 | | /// <param name='versionId'> |
| | 789 | | /// The version ID. |
| | 790 | | /// </param> |
| | 791 | | /// <param name='skip'> |
| | 792 | | /// The number of entries to skip. Default value is 0. |
| | 793 | | /// </param> |
| | 794 | | /// <param name='take'> |
| | 795 | | /// The number of entries to return. Maximum page size is 500. Default is 100. |
| | 796 | | /// </param> |
| | 797 | | /// <param name='customHeaders'> |
| | 798 | | /// Headers that will be added to request. |
| | 799 | | /// </param> |
| | 800 | | /// <param name='cancellationToken'> |
| | 801 | | /// The cancellation token. |
| | 802 | | /// </param> |
| | 803 | | /// <exception cref="ErrorResponseException"> |
| | 804 | | /// Thrown when the operation returned an invalid status code |
| | 805 | | /// </exception> |
| | 806 | | /// <exception cref="SerializationException"> |
| | 807 | | /// Thrown when unable to deserialize the response |
| | 808 | | /// </exception> |
| | 809 | | /// <exception cref="ValidationException"> |
| | 810 | | /// Thrown when a required parameter is null |
| | 811 | | /// </exception> |
| | 812 | | /// <exception cref="System.ArgumentNullException"> |
| | 813 | | /// Thrown when a required parameter is null |
| | 814 | | /// </exception> |
| | 815 | | /// <return> |
| | 816 | | /// A response object containing the response body and response headers. |
| | 817 | | /// </return> |
| | 818 | | public async Task<HttpOperationResponse<IList<HierarchicalEntityExtractor>>> ListHierarchicalEntitiesWithHttpMes |
| | 819 | | { |
| 0 | 820 | | if (Client.Endpoint == null) |
| | 821 | | { |
| 0 | 822 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 823 | | } |
| 0 | 824 | | if (versionId == null) |
| | 825 | | { |
| 0 | 826 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 827 | | } |
| 0 | 828 | | if (skip < 0) |
| | 829 | | { |
| 0 | 830 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0); |
| | 831 | | } |
| 0 | 832 | | if (take > 500) |
| | 833 | | { |
| 0 | 834 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500); |
| | 835 | | } |
| 0 | 836 | | if (take < 0) |
| | 837 | | { |
| 0 | 838 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0); |
| | 839 | | } |
| | 840 | | // Tracing |
| 0 | 841 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 842 | | string _invocationId = null; |
| 0 | 843 | | if (_shouldTrace) |
| | 844 | | { |
| 0 | 845 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 846 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 847 | | tracingParameters.Add("appId", appId); |
| 0 | 848 | | tracingParameters.Add("versionId", versionId); |
| 0 | 849 | | tracingParameters.Add("skip", skip); |
| 0 | 850 | | tracingParameters.Add("take", take); |
| 0 | 851 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 852 | | ServiceClientTracing.Enter(_invocationId, this, "ListHierarchicalEntities", tracingParameters); |
| | 853 | | } |
| | 854 | | // Construct URL |
| 0 | 855 | | var _baseUrl = Client.BaseUri; |
| 0 | 856 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale |
| 0 | 857 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 858 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 859 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 860 | | List<string> _queryParameters = new List<string>(); |
| 0 | 861 | | if (skip != null) |
| | 862 | | { |
| 0 | 863 | | _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 864 | | } |
| 0 | 865 | | if (take != null) |
| | 866 | | { |
| 0 | 867 | | _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 868 | | } |
| 0 | 869 | | if (_queryParameters.Count > 0) |
| | 870 | | { |
| 0 | 871 | | _url += "?" + string.Join("&", _queryParameters); |
| | 872 | | } |
| | 873 | | // Create HTTP transport objects |
| 0 | 874 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 875 | | HttpResponseMessage _httpResponse = null; |
| 0 | 876 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 877 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 878 | | // Set Headers |
| | 879 | |
|
| | 880 | |
|
| 0 | 881 | | if (customHeaders != null) |
| | 882 | | { |
| 0 | 883 | | foreach(var _header in customHeaders) |
| | 884 | | { |
| 0 | 885 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 886 | | { |
| 0 | 887 | | _httpRequest.Headers.Remove(_header.Key); |
| | 888 | | } |
| 0 | 889 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 890 | | } |
| | 891 | | } |
| | 892 | |
|
| | 893 | | // Serialize Request |
| 0 | 894 | | string _requestContent = null; |
| | 895 | | // Set Credentials |
| 0 | 896 | | if (Client.Credentials != null) |
| | 897 | | { |
| 0 | 898 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 899 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 900 | | } |
| | 901 | | // Send Request |
| 0 | 902 | | if (_shouldTrace) |
| | 903 | | { |
| 0 | 904 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 905 | | } |
| 0 | 906 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 907 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 908 | | if (_shouldTrace) |
| | 909 | | { |
| 0 | 910 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 911 | | } |
| 0 | 912 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 913 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 914 | | string _responseContent = null; |
| 0 | 915 | | if ((int)_statusCode != 200) |
| | 916 | | { |
| 0 | 917 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 918 | | try |
| | 919 | | { |
| 0 | 920 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 921 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 922 | | if (_errorBody != null) |
| | 923 | | { |
| 0 | 924 | | ex.Body = _errorBody; |
| | 925 | | } |
| 0 | 926 | | } |
| 0 | 927 | | catch (JsonException) |
| | 928 | | { |
| | 929 | | // Ignore the exception |
| 0 | 930 | | } |
| 0 | 931 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 932 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 933 | | if (_shouldTrace) |
| | 934 | | { |
| 0 | 935 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 936 | | } |
| 0 | 937 | | _httpRequest.Dispose(); |
| 0 | 938 | | if (_httpResponse != null) |
| | 939 | | { |
| 0 | 940 | | _httpResponse.Dispose(); |
| | 941 | | } |
| 0 | 942 | | throw ex; |
| | 943 | | } |
| | 944 | | // Create Result |
| 0 | 945 | | var _result = new HttpOperationResponse<IList<HierarchicalEntityExtractor>>(); |
| 0 | 946 | | _result.Request = _httpRequest; |
| 0 | 947 | | _result.Response = _httpResponse; |
| | 948 | | // Deserialize Response |
| 0 | 949 | | if ((int)_statusCode == 200) |
| | 950 | | { |
| 0 | 951 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 952 | | try |
| | 953 | | { |
| 0 | 954 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<HierarchicalEntityExtracto |
| 0 | 955 | | } |
| 0 | 956 | | catch (JsonException ex) |
| | 957 | | { |
| 0 | 958 | | _httpRequest.Dispose(); |
| 0 | 959 | | if (_httpResponse != null) |
| | 960 | | { |
| 0 | 961 | | _httpResponse.Dispose(); |
| | 962 | | } |
| 0 | 963 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 964 | | } |
| | 965 | | } |
| 0 | 966 | | if (_shouldTrace) |
| | 967 | | { |
| 0 | 968 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 969 | | } |
| 0 | 970 | | return _result; |
| 0 | 971 | | } |
| | 972 | |
|
| | 973 | | /// <summary> |
| | 974 | | /// Gets information about all the composite entity models in a version of the |
| | 975 | | /// application. |
| | 976 | | /// </summary> |
| | 977 | | /// <param name='appId'> |
| | 978 | | /// The application ID. |
| | 979 | | /// </param> |
| | 980 | | /// <param name='versionId'> |
| | 981 | | /// The version ID. |
| | 982 | | /// </param> |
| | 983 | | /// <param name='skip'> |
| | 984 | | /// The number of entries to skip. Default value is 0. |
| | 985 | | /// </param> |
| | 986 | | /// <param name='take'> |
| | 987 | | /// The number of entries to return. Maximum page size is 500. Default is 100. |
| | 988 | | /// </param> |
| | 989 | | /// <param name='customHeaders'> |
| | 990 | | /// Headers that will be added to request. |
| | 991 | | /// </param> |
| | 992 | | /// <param name='cancellationToken'> |
| | 993 | | /// The cancellation token. |
| | 994 | | /// </param> |
| | 995 | | /// <exception cref="ErrorResponseException"> |
| | 996 | | /// Thrown when the operation returned an invalid status code |
| | 997 | | /// </exception> |
| | 998 | | /// <exception cref="SerializationException"> |
| | 999 | | /// Thrown when unable to deserialize the response |
| | 1000 | | /// </exception> |
| | 1001 | | /// <exception cref="ValidationException"> |
| | 1002 | | /// Thrown when a required parameter is null |
| | 1003 | | /// </exception> |
| | 1004 | | /// <exception cref="System.ArgumentNullException"> |
| | 1005 | | /// Thrown when a required parameter is null |
| | 1006 | | /// </exception> |
| | 1007 | | /// <return> |
| | 1008 | | /// A response object containing the response body and response headers. |
| | 1009 | | /// </return> |
| | 1010 | | public async Task<HttpOperationResponse<IList<CompositeEntityExtractor>>> ListCompositeEntitiesWithHttpMessagesA |
| | 1011 | | { |
| 0 | 1012 | | if (Client.Endpoint == null) |
| | 1013 | | { |
| 0 | 1014 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 1015 | | } |
| 0 | 1016 | | if (versionId == null) |
| | 1017 | | { |
| 0 | 1018 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 1019 | | } |
| 0 | 1020 | | if (skip < 0) |
| | 1021 | | { |
| 0 | 1022 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0); |
| | 1023 | | } |
| 0 | 1024 | | if (take > 500) |
| | 1025 | | { |
| 0 | 1026 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500); |
| | 1027 | | } |
| 0 | 1028 | | if (take < 0) |
| | 1029 | | { |
| 0 | 1030 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0); |
| | 1031 | | } |
| | 1032 | | // Tracing |
| 0 | 1033 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 1034 | | string _invocationId = null; |
| 0 | 1035 | | if (_shouldTrace) |
| | 1036 | | { |
| 0 | 1037 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 1038 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 1039 | | tracingParameters.Add("appId", appId); |
| 0 | 1040 | | tracingParameters.Add("versionId", versionId); |
| 0 | 1041 | | tracingParameters.Add("skip", skip); |
| 0 | 1042 | | tracingParameters.Add("take", take); |
| 0 | 1043 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1044 | | ServiceClientTracing.Enter(_invocationId, this, "ListCompositeEntities", tracingParameters); |
| | 1045 | | } |
| | 1046 | | // Construct URL |
| 0 | 1047 | | var _baseUrl = Client.BaseUri; |
| 0 | 1048 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti |
| 0 | 1049 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 1050 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 1051 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 1052 | | List<string> _queryParameters = new List<string>(); |
| 0 | 1053 | | if (skip != null) |
| | 1054 | | { |
| 0 | 1055 | | _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 1056 | | } |
| 0 | 1057 | | if (take != null) |
| | 1058 | | { |
| 0 | 1059 | | _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 1060 | | } |
| 0 | 1061 | | if (_queryParameters.Count > 0) |
| | 1062 | | { |
| 0 | 1063 | | _url += "?" + string.Join("&", _queryParameters); |
| | 1064 | | } |
| | 1065 | | // Create HTTP transport objects |
| 0 | 1066 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 1067 | | HttpResponseMessage _httpResponse = null; |
| 0 | 1068 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 1069 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1070 | | // Set Headers |
| | 1071 | |
|
| | 1072 | |
|
| 0 | 1073 | | if (customHeaders != null) |
| | 1074 | | { |
| 0 | 1075 | | foreach(var _header in customHeaders) |
| | 1076 | | { |
| 0 | 1077 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 1078 | | { |
| 0 | 1079 | | _httpRequest.Headers.Remove(_header.Key); |
| | 1080 | | } |
| 0 | 1081 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 1082 | | } |
| | 1083 | | } |
| | 1084 | |
|
| | 1085 | | // Serialize Request |
| 0 | 1086 | | string _requestContent = null; |
| | 1087 | | // Set Credentials |
| 0 | 1088 | | if (Client.Credentials != null) |
| | 1089 | | { |
| 0 | 1090 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1091 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 1092 | | } |
| | 1093 | | // Send Request |
| 0 | 1094 | | if (_shouldTrace) |
| | 1095 | | { |
| 0 | 1096 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 1097 | | } |
| 0 | 1098 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1099 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 1100 | | if (_shouldTrace) |
| | 1101 | | { |
| 0 | 1102 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 1103 | | } |
| 0 | 1104 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 1105 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 1106 | | string _responseContent = null; |
| 0 | 1107 | | if ((int)_statusCode != 200) |
| | 1108 | | { |
| 0 | 1109 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 1110 | | try |
| | 1111 | | { |
| 0 | 1112 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 1113 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 1114 | | if (_errorBody != null) |
| | 1115 | | { |
| 0 | 1116 | | ex.Body = _errorBody; |
| | 1117 | | } |
| 0 | 1118 | | } |
| 0 | 1119 | | catch (JsonException) |
| | 1120 | | { |
| | 1121 | | // Ignore the exception |
| 0 | 1122 | | } |
| 0 | 1123 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 1124 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 1125 | | if (_shouldTrace) |
| | 1126 | | { |
| 0 | 1127 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 1128 | | } |
| 0 | 1129 | | _httpRequest.Dispose(); |
| 0 | 1130 | | if (_httpResponse != null) |
| | 1131 | | { |
| 0 | 1132 | | _httpResponse.Dispose(); |
| | 1133 | | } |
| 0 | 1134 | | throw ex; |
| | 1135 | | } |
| | 1136 | | // Create Result |
| 0 | 1137 | | var _result = new HttpOperationResponse<IList<CompositeEntityExtractor>>(); |
| 0 | 1138 | | _result.Request = _httpRequest; |
| 0 | 1139 | | _result.Response = _httpResponse; |
| | 1140 | | // Deserialize Response |
| 0 | 1141 | | if ((int)_statusCode == 200) |
| | 1142 | | { |
| 0 | 1143 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 1144 | | try |
| | 1145 | | { |
| 0 | 1146 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<CompositeEntityExtractor>> |
| 0 | 1147 | | } |
| 0 | 1148 | | catch (JsonException ex) |
| | 1149 | | { |
| 0 | 1150 | | _httpRequest.Dispose(); |
| 0 | 1151 | | if (_httpResponse != null) |
| | 1152 | | { |
| 0 | 1153 | | _httpResponse.Dispose(); |
| | 1154 | | } |
| 0 | 1155 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 1156 | | } |
| | 1157 | | } |
| 0 | 1158 | | if (_shouldTrace) |
| | 1159 | | { |
| 0 | 1160 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 1161 | | } |
| 0 | 1162 | | return _result; |
| 0 | 1163 | | } |
| | 1164 | |
|
| | 1165 | | /// <summary> |
| | 1166 | | /// Gets information about all the list entity models in a version of the |
| | 1167 | | /// application. |
| | 1168 | | /// </summary> |
| | 1169 | | /// <param name='appId'> |
| | 1170 | | /// The application ID. |
| | 1171 | | /// </param> |
| | 1172 | | /// <param name='versionId'> |
| | 1173 | | /// The version ID. |
| | 1174 | | /// </param> |
| | 1175 | | /// <param name='skip'> |
| | 1176 | | /// The number of entries to skip. Default value is 0. |
| | 1177 | | /// </param> |
| | 1178 | | /// <param name='take'> |
| | 1179 | | /// The number of entries to return. Maximum page size is 500. Default is 100. |
| | 1180 | | /// </param> |
| | 1181 | | /// <param name='customHeaders'> |
| | 1182 | | /// Headers that will be added to request. |
| | 1183 | | /// </param> |
| | 1184 | | /// <param name='cancellationToken'> |
| | 1185 | | /// The cancellation token. |
| | 1186 | | /// </param> |
| | 1187 | | /// <exception cref="ErrorResponseException"> |
| | 1188 | | /// Thrown when the operation returned an invalid status code |
| | 1189 | | /// </exception> |
| | 1190 | | /// <exception cref="SerializationException"> |
| | 1191 | | /// Thrown when unable to deserialize the response |
| | 1192 | | /// </exception> |
| | 1193 | | /// <exception cref="ValidationException"> |
| | 1194 | | /// Thrown when a required parameter is null |
| | 1195 | | /// </exception> |
| | 1196 | | /// <exception cref="System.ArgumentNullException"> |
| | 1197 | | /// Thrown when a required parameter is null |
| | 1198 | | /// </exception> |
| | 1199 | | /// <return> |
| | 1200 | | /// A response object containing the response body and response headers. |
| | 1201 | | /// </return> |
| | 1202 | | public async Task<HttpOperationResponse<IList<ClosedListEntityExtractor>>> ListClosedListsWithHttpMessagesAsync( |
| | 1203 | | { |
| 2 | 1204 | | if (Client.Endpoint == null) |
| | 1205 | | { |
| 0 | 1206 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 1207 | | } |
| 2 | 1208 | | if (versionId == null) |
| | 1209 | | { |
| 0 | 1210 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 1211 | | } |
| 2 | 1212 | | if (skip < 0) |
| | 1213 | | { |
| 0 | 1214 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0); |
| | 1215 | | } |
| 2 | 1216 | | if (take > 500) |
| | 1217 | | { |
| 0 | 1218 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500); |
| | 1219 | | } |
| 2 | 1220 | | if (take < 0) |
| | 1221 | | { |
| 0 | 1222 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0); |
| | 1223 | | } |
| | 1224 | | // Tracing |
| 2 | 1225 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 1226 | | string _invocationId = null; |
| 2 | 1227 | | if (_shouldTrace) |
| | 1228 | | { |
| 0 | 1229 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 1230 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 1231 | | tracingParameters.Add("appId", appId); |
| 0 | 1232 | | tracingParameters.Add("versionId", versionId); |
| 0 | 1233 | | tracingParameters.Add("skip", skip); |
| 0 | 1234 | | tracingParameters.Add("take", take); |
| 0 | 1235 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1236 | | ServiceClientTracing.Enter(_invocationId, this, "ListClosedLists", tracingParameters); |
| | 1237 | | } |
| | 1238 | | // Construct URL |
| 2 | 1239 | | var _baseUrl = Client.BaseUri; |
| 2 | 1240 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists"; |
| 2 | 1241 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 1242 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 1243 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 2 | 1244 | | List<string> _queryParameters = new List<string>(); |
| 2 | 1245 | | if (skip != null) |
| | 1246 | | { |
| 2 | 1247 | | _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 1248 | | } |
| 2 | 1249 | | if (take != null) |
| | 1250 | | { |
| 2 | 1251 | | _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 1252 | | } |
| 2 | 1253 | | if (_queryParameters.Count > 0) |
| | 1254 | | { |
| 2 | 1255 | | _url += "?" + string.Join("&", _queryParameters); |
| | 1256 | | } |
| | 1257 | | // Create HTTP transport objects |
| 2 | 1258 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 1259 | | HttpResponseMessage _httpResponse = null; |
| 2 | 1260 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 1261 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1262 | | // Set Headers |
| | 1263 | |
|
| | 1264 | |
|
| 2 | 1265 | | if (customHeaders != null) |
| | 1266 | | { |
| 0 | 1267 | | foreach(var _header in customHeaders) |
| | 1268 | | { |
| 0 | 1269 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 1270 | | { |
| 0 | 1271 | | _httpRequest.Headers.Remove(_header.Key); |
| | 1272 | | } |
| 0 | 1273 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 1274 | | } |
| | 1275 | | } |
| | 1276 | |
|
| | 1277 | | // Serialize Request |
| 2 | 1278 | | string _requestContent = null; |
| | 1279 | | // Set Credentials |
| 2 | 1280 | | if (Client.Credentials != null) |
| | 1281 | | { |
| 2 | 1282 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 1283 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 1284 | | } |
| | 1285 | | // Send Request |
| 2 | 1286 | | if (_shouldTrace) |
| | 1287 | | { |
| 0 | 1288 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 1289 | | } |
| 2 | 1290 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 1291 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 1292 | | if (_shouldTrace) |
| | 1293 | | { |
| 0 | 1294 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 1295 | | } |
| 2 | 1296 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 1297 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 1298 | | string _responseContent = null; |
| 2 | 1299 | | if ((int)_statusCode != 200) |
| | 1300 | | { |
| 0 | 1301 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 1302 | | try |
| | 1303 | | { |
| 0 | 1304 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 1305 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 1306 | | if (_errorBody != null) |
| | 1307 | | { |
| 0 | 1308 | | ex.Body = _errorBody; |
| | 1309 | | } |
| 0 | 1310 | | } |
| 0 | 1311 | | catch (JsonException) |
| | 1312 | | { |
| | 1313 | | // Ignore the exception |
| 0 | 1314 | | } |
| 0 | 1315 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 1316 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 1317 | | if (_shouldTrace) |
| | 1318 | | { |
| 0 | 1319 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 1320 | | } |
| 0 | 1321 | | _httpRequest.Dispose(); |
| 0 | 1322 | | if (_httpResponse != null) |
| | 1323 | | { |
| 0 | 1324 | | _httpResponse.Dispose(); |
| | 1325 | | } |
| 0 | 1326 | | throw ex; |
| | 1327 | | } |
| | 1328 | | // Create Result |
| 2 | 1329 | | var _result = new HttpOperationResponse<IList<ClosedListEntityExtractor>>(); |
| 2 | 1330 | | _result.Request = _httpRequest; |
| 2 | 1331 | | _result.Response = _httpResponse; |
| | 1332 | | // Deserialize Response |
| 2 | 1333 | | if ((int)_statusCode == 200) |
| | 1334 | | { |
| 2 | 1335 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 1336 | | try |
| | 1337 | | { |
| 2 | 1338 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<ClosedListEntityExtractor> |
| 2 | 1339 | | } |
| 0 | 1340 | | catch (JsonException ex) |
| | 1341 | | { |
| 0 | 1342 | | _httpRequest.Dispose(); |
| 0 | 1343 | | if (_httpResponse != null) |
| | 1344 | | { |
| 0 | 1345 | | _httpResponse.Dispose(); |
| | 1346 | | } |
| 0 | 1347 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 1348 | | } |
| | 1349 | | } |
| 2 | 1350 | | if (_shouldTrace) |
| | 1351 | | { |
| 0 | 1352 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 1353 | | } |
| 2 | 1354 | | return _result; |
| 2 | 1355 | | } |
| | 1356 | |
|
| | 1357 | | /// <summary> |
| | 1358 | | /// Adds a list entity model to a version of the application. |
| | 1359 | | /// </summary> |
| | 1360 | | /// <param name='appId'> |
| | 1361 | | /// The application ID. |
| | 1362 | | /// </param> |
| | 1363 | | /// <param name='versionId'> |
| | 1364 | | /// The version ID. |
| | 1365 | | /// </param> |
| | 1366 | | /// <param name='closedListModelCreateObject'> |
| | 1367 | | /// A model containing the name and words for the new list entity extractor. |
| | 1368 | | /// </param> |
| | 1369 | | /// <param name='customHeaders'> |
| | 1370 | | /// Headers that will be added to request. |
| | 1371 | | /// </param> |
| | 1372 | | /// <param name='cancellationToken'> |
| | 1373 | | /// The cancellation token. |
| | 1374 | | /// </param> |
| | 1375 | | /// <exception cref="ErrorResponseException"> |
| | 1376 | | /// Thrown when the operation returned an invalid status code |
| | 1377 | | /// </exception> |
| | 1378 | | /// <exception cref="SerializationException"> |
| | 1379 | | /// Thrown when unable to deserialize the response |
| | 1380 | | /// </exception> |
| | 1381 | | /// <exception cref="ValidationException"> |
| | 1382 | | /// Thrown when a required parameter is null |
| | 1383 | | /// </exception> |
| | 1384 | | /// <exception cref="System.ArgumentNullException"> |
| | 1385 | | /// Thrown when a required parameter is null |
| | 1386 | | /// </exception> |
| | 1387 | | /// <return> |
| | 1388 | | /// A response object containing the response body and response headers. |
| | 1389 | | /// </return> |
| | 1390 | | public async Task<HttpOperationResponse<System.Guid>> AddClosedListWithHttpMessagesAsync(System.Guid appId, stri |
| | 1391 | | { |
| 14 | 1392 | | if (Client.Endpoint == null) |
| | 1393 | | { |
| 0 | 1394 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 1395 | | } |
| 14 | 1396 | | if (versionId == null) |
| | 1397 | | { |
| 0 | 1398 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 1399 | | } |
| 14 | 1400 | | if (closedListModelCreateObject == null) |
| | 1401 | | { |
| 0 | 1402 | | throw new ValidationException(ValidationRules.CannotBeNull, "closedListModelCreateObject"); |
| | 1403 | | } |
| | 1404 | | // Tracing |
| 14 | 1405 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 14 | 1406 | | string _invocationId = null; |
| 14 | 1407 | | if (_shouldTrace) |
| | 1408 | | { |
| 0 | 1409 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 1410 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 1411 | | tracingParameters.Add("appId", appId); |
| 0 | 1412 | | tracingParameters.Add("versionId", versionId); |
| 0 | 1413 | | tracingParameters.Add("closedListModelCreateObject", closedListModelCreateObject); |
| 0 | 1414 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1415 | | ServiceClientTracing.Enter(_invocationId, this, "AddClosedList", tracingParameters); |
| | 1416 | | } |
| | 1417 | | // Construct URL |
| 14 | 1418 | | var _baseUrl = Client.BaseUri; |
| 14 | 1419 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists"; |
| 14 | 1420 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 14 | 1421 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 14 | 1422 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| | 1423 | | // Create HTTP transport objects |
| 14 | 1424 | | var _httpRequest = new HttpRequestMessage(); |
| 14 | 1425 | | HttpResponseMessage _httpResponse = null; |
| 14 | 1426 | | _httpRequest.Method = new HttpMethod("POST"); |
| 14 | 1427 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1428 | | // Set Headers |
| | 1429 | |
|
| | 1430 | |
|
| 14 | 1431 | | if (customHeaders != null) |
| | 1432 | | { |
| 0 | 1433 | | foreach(var _header in customHeaders) |
| | 1434 | | { |
| 0 | 1435 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 1436 | | { |
| 0 | 1437 | | _httpRequest.Headers.Remove(_header.Key); |
| | 1438 | | } |
| 0 | 1439 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 1440 | | } |
| | 1441 | | } |
| | 1442 | |
|
| | 1443 | | // Serialize Request |
| 14 | 1444 | | string _requestContent = null; |
| 14 | 1445 | | if(closedListModelCreateObject != null) |
| | 1446 | | { |
| 14 | 1447 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(closedListModelCreateObject, Client |
| 14 | 1448 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 14 | 1449 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 1450 | | } |
| | 1451 | | // Set Credentials |
| 14 | 1452 | | if (Client.Credentials != null) |
| | 1453 | | { |
| 14 | 1454 | | cancellationToken.ThrowIfCancellationRequested(); |
| 14 | 1455 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 1456 | | } |
| | 1457 | | // Send Request |
| 14 | 1458 | | if (_shouldTrace) |
| | 1459 | | { |
| 0 | 1460 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 1461 | | } |
| 14 | 1462 | | cancellationToken.ThrowIfCancellationRequested(); |
| 14 | 1463 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 14 | 1464 | | if (_shouldTrace) |
| | 1465 | | { |
| 0 | 1466 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 1467 | | } |
| 14 | 1468 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 14 | 1469 | | cancellationToken.ThrowIfCancellationRequested(); |
| 14 | 1470 | | string _responseContent = null; |
| 14 | 1471 | | if ((int)_statusCode != 201) |
| | 1472 | | { |
| 0 | 1473 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 1474 | | try |
| | 1475 | | { |
| 0 | 1476 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 1477 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 1478 | | if (_errorBody != null) |
| | 1479 | | { |
| 0 | 1480 | | ex.Body = _errorBody; |
| | 1481 | | } |
| 0 | 1482 | | } |
| 0 | 1483 | | catch (JsonException) |
| | 1484 | | { |
| | 1485 | | // Ignore the exception |
| 0 | 1486 | | } |
| 0 | 1487 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 1488 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 1489 | | if (_shouldTrace) |
| | 1490 | | { |
| 0 | 1491 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 1492 | | } |
| 0 | 1493 | | _httpRequest.Dispose(); |
| 0 | 1494 | | if (_httpResponse != null) |
| | 1495 | | { |
| 0 | 1496 | | _httpResponse.Dispose(); |
| | 1497 | | } |
| 0 | 1498 | | throw ex; |
| | 1499 | | } |
| | 1500 | | // Create Result |
| 14 | 1501 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 14 | 1502 | | _result.Request = _httpRequest; |
| 14 | 1503 | | _result.Response = _httpResponse; |
| | 1504 | | // Deserialize Response |
| 14 | 1505 | | if ((int)_statusCode == 201) |
| | 1506 | | { |
| 14 | 1507 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 1508 | | try |
| | 1509 | | { |
| 14 | 1510 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 14 | 1511 | | } |
| 0 | 1512 | | catch (JsonException ex) |
| | 1513 | | { |
| 0 | 1514 | | _httpRequest.Dispose(); |
| 0 | 1515 | | if (_httpResponse != null) |
| | 1516 | | { |
| 0 | 1517 | | _httpResponse.Dispose(); |
| | 1518 | | } |
| 0 | 1519 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 1520 | | } |
| | 1521 | | } |
| 14 | 1522 | | if (_shouldTrace) |
| | 1523 | | { |
| 0 | 1524 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 1525 | | } |
| 14 | 1526 | | return _result; |
| 14 | 1527 | | } |
| | 1528 | |
|
| | 1529 | | /// <summary> |
| | 1530 | | /// Adds a list of prebuilt entities to a version of the application. |
| | 1531 | | /// </summary> |
| | 1532 | | /// <param name='appId'> |
| | 1533 | | /// The application ID. |
| | 1534 | | /// </param> |
| | 1535 | | /// <param name='versionId'> |
| | 1536 | | /// The version ID. |
| | 1537 | | /// </param> |
| | 1538 | | /// <param name='prebuiltExtractorNames'> |
| | 1539 | | /// An array of prebuilt entity extractor names. |
| | 1540 | | /// </param> |
| | 1541 | | /// <param name='customHeaders'> |
| | 1542 | | /// Headers that will be added to request. |
| | 1543 | | /// </param> |
| | 1544 | | /// <param name='cancellationToken'> |
| | 1545 | | /// The cancellation token. |
| | 1546 | | /// </param> |
| | 1547 | | /// <exception cref="ErrorResponseException"> |
| | 1548 | | /// Thrown when the operation returned an invalid status code |
| | 1549 | | /// </exception> |
| | 1550 | | /// <exception cref="SerializationException"> |
| | 1551 | | /// Thrown when unable to deserialize the response |
| | 1552 | | /// </exception> |
| | 1553 | | /// <exception cref="ValidationException"> |
| | 1554 | | /// Thrown when a required parameter is null |
| | 1555 | | /// </exception> |
| | 1556 | | /// <exception cref="System.ArgumentNullException"> |
| | 1557 | | /// Thrown when a required parameter is null |
| | 1558 | | /// </exception> |
| | 1559 | | /// <return> |
| | 1560 | | /// A response object containing the response body and response headers. |
| | 1561 | | /// </return> |
| | 1562 | | public async Task<HttpOperationResponse<IList<PrebuiltEntityExtractor>>> AddPrebuiltWithHttpMessagesAsync(System |
| | 1563 | | { |
| 19 | 1564 | | if (Client.Endpoint == null) |
| | 1565 | | { |
| 0 | 1566 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 1567 | | } |
| 19 | 1568 | | if (versionId == null) |
| | 1569 | | { |
| 0 | 1570 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 1571 | | } |
| 19 | 1572 | | if (prebuiltExtractorNames == null) |
| | 1573 | | { |
| 0 | 1574 | | throw new ValidationException(ValidationRules.CannotBeNull, "prebuiltExtractorNames"); |
| | 1575 | | } |
| | 1576 | | // Tracing |
| 19 | 1577 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 19 | 1578 | | string _invocationId = null; |
| 19 | 1579 | | if (_shouldTrace) |
| | 1580 | | { |
| 0 | 1581 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 1582 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 1583 | | tracingParameters.Add("appId", appId); |
| 0 | 1584 | | tracingParameters.Add("versionId", versionId); |
| 0 | 1585 | | tracingParameters.Add("prebuiltExtractorNames", prebuiltExtractorNames); |
| 0 | 1586 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1587 | | ServiceClientTracing.Enter(_invocationId, this, "AddPrebuilt", tracingParameters); |
| | 1588 | | } |
| | 1589 | | // Construct URL |
| 19 | 1590 | | var _baseUrl = Client.BaseUri; |
| 19 | 1591 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts"; |
| 19 | 1592 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 19 | 1593 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 19 | 1594 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| | 1595 | | // Create HTTP transport objects |
| 19 | 1596 | | var _httpRequest = new HttpRequestMessage(); |
| 19 | 1597 | | HttpResponseMessage _httpResponse = null; |
| 19 | 1598 | | _httpRequest.Method = new HttpMethod("POST"); |
| 19 | 1599 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1600 | | // Set Headers |
| | 1601 | |
|
| | 1602 | |
|
| 19 | 1603 | | if (customHeaders != null) |
| | 1604 | | { |
| 0 | 1605 | | foreach(var _header in customHeaders) |
| | 1606 | | { |
| 0 | 1607 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 1608 | | { |
| 0 | 1609 | | _httpRequest.Headers.Remove(_header.Key); |
| | 1610 | | } |
| 0 | 1611 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 1612 | | } |
| | 1613 | | } |
| | 1614 | |
|
| | 1615 | | // Serialize Request |
| 19 | 1616 | | string _requestContent = null; |
| 19 | 1617 | | if(prebuiltExtractorNames != null) |
| | 1618 | | { |
| 19 | 1619 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(prebuiltExtractorNames, Client.Seri |
| 19 | 1620 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 19 | 1621 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 1622 | | } |
| | 1623 | | // Set Credentials |
| 19 | 1624 | | if (Client.Credentials != null) |
| | 1625 | | { |
| 19 | 1626 | | cancellationToken.ThrowIfCancellationRequested(); |
| 19 | 1627 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 1628 | | } |
| | 1629 | | // Send Request |
| 19 | 1630 | | if (_shouldTrace) |
| | 1631 | | { |
| 0 | 1632 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 1633 | | } |
| 19 | 1634 | | cancellationToken.ThrowIfCancellationRequested(); |
| 19 | 1635 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 19 | 1636 | | if (_shouldTrace) |
| | 1637 | | { |
| 0 | 1638 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 1639 | | } |
| 19 | 1640 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 19 | 1641 | | cancellationToken.ThrowIfCancellationRequested(); |
| 19 | 1642 | | string _responseContent = null; |
| 19 | 1643 | | if ((int)_statusCode != 201) |
| | 1644 | | { |
| 0 | 1645 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 1646 | | try |
| | 1647 | | { |
| 0 | 1648 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 1649 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 1650 | | if (_errorBody != null) |
| | 1651 | | { |
| 0 | 1652 | | ex.Body = _errorBody; |
| | 1653 | | } |
| 0 | 1654 | | } |
| 0 | 1655 | | catch (JsonException) |
| | 1656 | | { |
| | 1657 | | // Ignore the exception |
| 0 | 1658 | | } |
| 0 | 1659 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 1660 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 1661 | | if (_shouldTrace) |
| | 1662 | | { |
| 0 | 1663 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 1664 | | } |
| 0 | 1665 | | _httpRequest.Dispose(); |
| 0 | 1666 | | if (_httpResponse != null) |
| | 1667 | | { |
| 0 | 1668 | | _httpResponse.Dispose(); |
| | 1669 | | } |
| 0 | 1670 | | throw ex; |
| | 1671 | | } |
| | 1672 | | // Create Result |
| 19 | 1673 | | var _result = new HttpOperationResponse<IList<PrebuiltEntityExtractor>>(); |
| 19 | 1674 | | _result.Request = _httpRequest; |
| 19 | 1675 | | _result.Response = _httpResponse; |
| | 1676 | | // Deserialize Response |
| 19 | 1677 | | if ((int)_statusCode == 201) |
| | 1678 | | { |
| 19 | 1679 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 1680 | | try |
| | 1681 | | { |
| 19 | 1682 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<PrebuiltEntityExtractor>>( |
| 19 | 1683 | | } |
| 0 | 1684 | | catch (JsonException ex) |
| | 1685 | | { |
| 0 | 1686 | | _httpRequest.Dispose(); |
| 0 | 1687 | | if (_httpResponse != null) |
| | 1688 | | { |
| 0 | 1689 | | _httpResponse.Dispose(); |
| | 1690 | | } |
| 0 | 1691 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 1692 | | } |
| | 1693 | | } |
| 19 | 1694 | | if (_shouldTrace) |
| | 1695 | | { |
| 0 | 1696 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 1697 | | } |
| 19 | 1698 | | return _result; |
| 19 | 1699 | | } |
| | 1700 | |
|
| | 1701 | | /// <summary> |
| | 1702 | | /// Gets information about all the prebuilt entities in a version of the |
| | 1703 | | /// application. |
| | 1704 | | /// </summary> |
| | 1705 | | /// <param name='appId'> |
| | 1706 | | /// The application ID. |
| | 1707 | | /// </param> |
| | 1708 | | /// <param name='versionId'> |
| | 1709 | | /// The version ID. |
| | 1710 | | /// </param> |
| | 1711 | | /// <param name='skip'> |
| | 1712 | | /// The number of entries to skip. Default value is 0. |
| | 1713 | | /// </param> |
| | 1714 | | /// <param name='take'> |
| | 1715 | | /// The number of entries to return. Maximum page size is 500. Default is 100. |
| | 1716 | | /// </param> |
| | 1717 | | /// <param name='customHeaders'> |
| | 1718 | | /// Headers that will be added to request. |
| | 1719 | | /// </param> |
| | 1720 | | /// <param name='cancellationToken'> |
| | 1721 | | /// The cancellation token. |
| | 1722 | | /// </param> |
| | 1723 | | /// <exception cref="ErrorResponseException"> |
| | 1724 | | /// Thrown when the operation returned an invalid status code |
| | 1725 | | /// </exception> |
| | 1726 | | /// <exception cref="SerializationException"> |
| | 1727 | | /// Thrown when unable to deserialize the response |
| | 1728 | | /// </exception> |
| | 1729 | | /// <exception cref="ValidationException"> |
| | 1730 | | /// Thrown when a required parameter is null |
| | 1731 | | /// </exception> |
| | 1732 | | /// <exception cref="System.ArgumentNullException"> |
| | 1733 | | /// Thrown when a required parameter is null |
| | 1734 | | /// </exception> |
| | 1735 | | /// <return> |
| | 1736 | | /// A response object containing the response body and response headers. |
| | 1737 | | /// </return> |
| | 1738 | | public async Task<HttpOperationResponse<IList<PrebuiltEntityExtractor>>> ListPrebuiltsWithHttpMessagesAsync(Syst |
| | 1739 | | { |
| 2 | 1740 | | if (Client.Endpoint == null) |
| | 1741 | | { |
| 0 | 1742 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 1743 | | } |
| 2 | 1744 | | if (versionId == null) |
| | 1745 | | { |
| 0 | 1746 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 1747 | | } |
| 2 | 1748 | | if (skip < 0) |
| | 1749 | | { |
| 0 | 1750 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0); |
| | 1751 | | } |
| 2 | 1752 | | if (take > 500) |
| | 1753 | | { |
| 0 | 1754 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500); |
| | 1755 | | } |
| 2 | 1756 | | if (take < 0) |
| | 1757 | | { |
| 0 | 1758 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0); |
| | 1759 | | } |
| | 1760 | | // Tracing |
| 2 | 1761 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 1762 | | string _invocationId = null; |
| 2 | 1763 | | if (_shouldTrace) |
| | 1764 | | { |
| 0 | 1765 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 1766 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 1767 | | tracingParameters.Add("appId", appId); |
| 0 | 1768 | | tracingParameters.Add("versionId", versionId); |
| 0 | 1769 | | tracingParameters.Add("skip", skip); |
| 0 | 1770 | | tracingParameters.Add("take", take); |
| 0 | 1771 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1772 | | ServiceClientTracing.Enter(_invocationId, this, "ListPrebuilts", tracingParameters); |
| | 1773 | | } |
| | 1774 | | // Construct URL |
| 2 | 1775 | | var _baseUrl = Client.BaseUri; |
| 2 | 1776 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts"; |
| 2 | 1777 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 1778 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 1779 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 2 | 1780 | | List<string> _queryParameters = new List<string>(); |
| 2 | 1781 | | if (skip != null) |
| | 1782 | | { |
| 2 | 1783 | | _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 1784 | | } |
| 2 | 1785 | | if (take != null) |
| | 1786 | | { |
| 2 | 1787 | | _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 1788 | | } |
| 2 | 1789 | | if (_queryParameters.Count > 0) |
| | 1790 | | { |
| 2 | 1791 | | _url += "?" + string.Join("&", _queryParameters); |
| | 1792 | | } |
| | 1793 | | // Create HTTP transport objects |
| 2 | 1794 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 1795 | | HttpResponseMessage _httpResponse = null; |
| 2 | 1796 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 1797 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1798 | | // Set Headers |
| | 1799 | |
|
| | 1800 | |
|
| 2 | 1801 | | if (customHeaders != null) |
| | 1802 | | { |
| 0 | 1803 | | foreach(var _header in customHeaders) |
| | 1804 | | { |
| 0 | 1805 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 1806 | | { |
| 0 | 1807 | | _httpRequest.Headers.Remove(_header.Key); |
| | 1808 | | } |
| 0 | 1809 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 1810 | | } |
| | 1811 | | } |
| | 1812 | |
|
| | 1813 | | // Serialize Request |
| 2 | 1814 | | string _requestContent = null; |
| | 1815 | | // Set Credentials |
| 2 | 1816 | | if (Client.Credentials != null) |
| | 1817 | | { |
| 2 | 1818 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 1819 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 1820 | | } |
| | 1821 | | // Send Request |
| 2 | 1822 | | if (_shouldTrace) |
| | 1823 | | { |
| 0 | 1824 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 1825 | | } |
| 2 | 1826 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 1827 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 1828 | | if (_shouldTrace) |
| | 1829 | | { |
| 0 | 1830 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 1831 | | } |
| 2 | 1832 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 1833 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 1834 | | string _responseContent = null; |
| 2 | 1835 | | if ((int)_statusCode != 200) |
| | 1836 | | { |
| 0 | 1837 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 1838 | | try |
| | 1839 | | { |
| 0 | 1840 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 1841 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 1842 | | if (_errorBody != null) |
| | 1843 | | { |
| 0 | 1844 | | ex.Body = _errorBody; |
| | 1845 | | } |
| 0 | 1846 | | } |
| 0 | 1847 | | catch (JsonException) |
| | 1848 | | { |
| | 1849 | | // Ignore the exception |
| 0 | 1850 | | } |
| 0 | 1851 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 1852 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 1853 | | if (_shouldTrace) |
| | 1854 | | { |
| 0 | 1855 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 1856 | | } |
| 0 | 1857 | | _httpRequest.Dispose(); |
| 0 | 1858 | | if (_httpResponse != null) |
| | 1859 | | { |
| 0 | 1860 | | _httpResponse.Dispose(); |
| | 1861 | | } |
| 0 | 1862 | | throw ex; |
| | 1863 | | } |
| | 1864 | | // Create Result |
| 2 | 1865 | | var _result = new HttpOperationResponse<IList<PrebuiltEntityExtractor>>(); |
| 2 | 1866 | | _result.Request = _httpRequest; |
| 2 | 1867 | | _result.Response = _httpResponse; |
| | 1868 | | // Deserialize Response |
| 2 | 1869 | | if ((int)_statusCode == 200) |
| | 1870 | | { |
| 2 | 1871 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 1872 | | try |
| | 1873 | | { |
| 2 | 1874 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<PrebuiltEntityExtractor>>( |
| 2 | 1875 | | } |
| 0 | 1876 | | catch (JsonException ex) |
| | 1877 | | { |
| 0 | 1878 | | _httpRequest.Dispose(); |
| 0 | 1879 | | if (_httpResponse != null) |
| | 1880 | | { |
| 0 | 1881 | | _httpResponse.Dispose(); |
| | 1882 | | } |
| 0 | 1883 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 1884 | | } |
| | 1885 | | } |
| 2 | 1886 | | if (_shouldTrace) |
| | 1887 | | { |
| 0 | 1888 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 1889 | | } |
| 2 | 1890 | | return _result; |
| 2 | 1891 | | } |
| | 1892 | |
|
| | 1893 | | /// <summary> |
| | 1894 | | /// Gets all the available prebuilt entities in a version of the application. |
| | 1895 | | /// </summary> |
| | 1896 | | /// <param name='appId'> |
| | 1897 | | /// The application ID. |
| | 1898 | | /// </param> |
| | 1899 | | /// <param name='versionId'> |
| | 1900 | | /// The version ID. |
| | 1901 | | /// </param> |
| | 1902 | | /// <param name='customHeaders'> |
| | 1903 | | /// Headers that will be added to request. |
| | 1904 | | /// </param> |
| | 1905 | | /// <param name='cancellationToken'> |
| | 1906 | | /// The cancellation token. |
| | 1907 | | /// </param> |
| | 1908 | | /// <exception cref="ErrorResponseException"> |
| | 1909 | | /// Thrown when the operation returned an invalid status code |
| | 1910 | | /// </exception> |
| | 1911 | | /// <exception cref="SerializationException"> |
| | 1912 | | /// Thrown when unable to deserialize the response |
| | 1913 | | /// </exception> |
| | 1914 | | /// <exception cref="ValidationException"> |
| | 1915 | | /// Thrown when a required parameter is null |
| | 1916 | | /// </exception> |
| | 1917 | | /// <exception cref="System.ArgumentNullException"> |
| | 1918 | | /// Thrown when a required parameter is null |
| | 1919 | | /// </exception> |
| | 1920 | | /// <return> |
| | 1921 | | /// A response object containing the response body and response headers. |
| | 1922 | | /// </return> |
| | 1923 | | public async Task<HttpOperationResponse<IList<AvailablePrebuiltEntityModel>>> ListPrebuiltEntitiesWithHttpMessag |
| | 1924 | | { |
| 1 | 1925 | | if (Client.Endpoint == null) |
| | 1926 | | { |
| 0 | 1927 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 1928 | | } |
| 1 | 1929 | | if (versionId == null) |
| | 1930 | | { |
| 0 | 1931 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 1932 | | } |
| | 1933 | | // Tracing |
| 1 | 1934 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 1935 | | string _invocationId = null; |
| 1 | 1936 | | if (_shouldTrace) |
| | 1937 | | { |
| 0 | 1938 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 1939 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 1940 | | tracingParameters.Add("appId", appId); |
| 0 | 1941 | | tracingParameters.Add("versionId", versionId); |
| 0 | 1942 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 1943 | | ServiceClientTracing.Enter(_invocationId, this, "ListPrebuiltEntities", tracingParameters); |
| | 1944 | | } |
| | 1945 | | // Construct URL |
| 1 | 1946 | | var _baseUrl = Client.BaseUri; |
| 1 | 1947 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/listprebuilts |
| 1 | 1948 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 1949 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 1950 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| | 1951 | | // Create HTTP transport objects |
| 1 | 1952 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 1953 | | HttpResponseMessage _httpResponse = null; |
| 1 | 1954 | | _httpRequest.Method = new HttpMethod("GET"); |
| 1 | 1955 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 1956 | | // Set Headers |
| | 1957 | |
|
| | 1958 | |
|
| 1 | 1959 | | if (customHeaders != null) |
| | 1960 | | { |
| 0 | 1961 | | foreach(var _header in customHeaders) |
| | 1962 | | { |
| 0 | 1963 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 1964 | | { |
| 0 | 1965 | | _httpRequest.Headers.Remove(_header.Key); |
| | 1966 | | } |
| 0 | 1967 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 1968 | | } |
| | 1969 | | } |
| | 1970 | |
|
| | 1971 | | // Serialize Request |
| 1 | 1972 | | string _requestContent = null; |
| | 1973 | | // Set Credentials |
| 1 | 1974 | | if (Client.Credentials != null) |
| | 1975 | | { |
| 1 | 1976 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 1977 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 1978 | | } |
| | 1979 | | // Send Request |
| 1 | 1980 | | if (_shouldTrace) |
| | 1981 | | { |
| 0 | 1982 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 1983 | | } |
| 1 | 1984 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 1985 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 1986 | | if (_shouldTrace) |
| | 1987 | | { |
| 0 | 1988 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 1989 | | } |
| 1 | 1990 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 1991 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 1992 | | string _responseContent = null; |
| 1 | 1993 | | if ((int)_statusCode != 200) |
| | 1994 | | { |
| 0 | 1995 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 1996 | | try |
| | 1997 | | { |
| 0 | 1998 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 1999 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 2000 | | if (_errorBody != null) |
| | 2001 | | { |
| 0 | 2002 | | ex.Body = _errorBody; |
| | 2003 | | } |
| 0 | 2004 | | } |
| 0 | 2005 | | catch (JsonException) |
| | 2006 | | { |
| | 2007 | | // Ignore the exception |
| 0 | 2008 | | } |
| 0 | 2009 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 2010 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 2011 | | if (_shouldTrace) |
| | 2012 | | { |
| 0 | 2013 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 2014 | | } |
| 0 | 2015 | | _httpRequest.Dispose(); |
| 0 | 2016 | | if (_httpResponse != null) |
| | 2017 | | { |
| 0 | 2018 | | _httpResponse.Dispose(); |
| | 2019 | | } |
| 0 | 2020 | | throw ex; |
| | 2021 | | } |
| | 2022 | | // Create Result |
| 1 | 2023 | | var _result = new HttpOperationResponse<IList<AvailablePrebuiltEntityModel>>(); |
| 1 | 2024 | | _result.Request = _httpRequest; |
| 1 | 2025 | | _result.Response = _httpResponse; |
| | 2026 | | // Deserialize Response |
| 1 | 2027 | | if ((int)_statusCode == 200) |
| | 2028 | | { |
| 1 | 2029 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 2030 | | try |
| | 2031 | | { |
| 1 | 2032 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<AvailablePrebuiltEntityMod |
| 1 | 2033 | | } |
| 0 | 2034 | | catch (JsonException ex) |
| | 2035 | | { |
| 0 | 2036 | | _httpRequest.Dispose(); |
| 0 | 2037 | | if (_httpResponse != null) |
| | 2038 | | { |
| 0 | 2039 | | _httpResponse.Dispose(); |
| | 2040 | | } |
| 0 | 2041 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 2042 | | } |
| | 2043 | | } |
| 1 | 2044 | | if (_shouldTrace) |
| | 2045 | | { |
| 0 | 2046 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 2047 | | } |
| 1 | 2048 | | return _result; |
| 1 | 2049 | | } |
| | 2050 | |
|
| | 2051 | | /// <summary> |
| | 2052 | | /// Gets information about all the intent and entity models in a version of the |
| | 2053 | | /// application. |
| | 2054 | | /// </summary> |
| | 2055 | | /// <param name='appId'> |
| | 2056 | | /// The application ID. |
| | 2057 | | /// </param> |
| | 2058 | | /// <param name='versionId'> |
| | 2059 | | /// The version ID. |
| | 2060 | | /// </param> |
| | 2061 | | /// <param name='skip'> |
| | 2062 | | /// The number of entries to skip. Default value is 0. |
| | 2063 | | /// </param> |
| | 2064 | | /// <param name='take'> |
| | 2065 | | /// The number of entries to return. Maximum page size is 500. Default is 100. |
| | 2066 | | /// </param> |
| | 2067 | | /// <param name='customHeaders'> |
| | 2068 | | /// Headers that will be added to request. |
| | 2069 | | /// </param> |
| | 2070 | | /// <param name='cancellationToken'> |
| | 2071 | | /// The cancellation token. |
| | 2072 | | /// </param> |
| | 2073 | | /// <exception cref="ErrorResponseException"> |
| | 2074 | | /// Thrown when the operation returned an invalid status code |
| | 2075 | | /// </exception> |
| | 2076 | | /// <exception cref="SerializationException"> |
| | 2077 | | /// Thrown when unable to deserialize the response |
| | 2078 | | /// </exception> |
| | 2079 | | /// <exception cref="ValidationException"> |
| | 2080 | | /// Thrown when a required parameter is null |
| | 2081 | | /// </exception> |
| | 2082 | | /// <exception cref="System.ArgumentNullException"> |
| | 2083 | | /// Thrown when a required parameter is null |
| | 2084 | | /// </exception> |
| | 2085 | | /// <return> |
| | 2086 | | /// A response object containing the response body and response headers. |
| | 2087 | | /// </return> |
| | 2088 | | public async Task<HttpOperationResponse<IList<ModelInfoResponse>>> ListModelsWithHttpMessagesAsync(System.Guid a |
| | 2089 | | { |
| 0 | 2090 | | if (Client.Endpoint == null) |
| | 2091 | | { |
| 0 | 2092 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 2093 | | } |
| 0 | 2094 | | if (versionId == null) |
| | 2095 | | { |
| 0 | 2096 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 2097 | | } |
| 0 | 2098 | | if (skip < 0) |
| | 2099 | | { |
| 0 | 2100 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0); |
| | 2101 | | } |
| 0 | 2102 | | if (take > 500) |
| | 2103 | | { |
| 0 | 2104 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500); |
| | 2105 | | } |
| 0 | 2106 | | if (take < 0) |
| | 2107 | | { |
| 0 | 2108 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0); |
| | 2109 | | } |
| | 2110 | | // Tracing |
| 0 | 2111 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 2112 | | string _invocationId = null; |
| 0 | 2113 | | if (_shouldTrace) |
| | 2114 | | { |
| 0 | 2115 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 2116 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 2117 | | tracingParameters.Add("appId", appId); |
| 0 | 2118 | | tracingParameters.Add("versionId", versionId); |
| 0 | 2119 | | tracingParameters.Add("skip", skip); |
| 0 | 2120 | | tracingParameters.Add("take", take); |
| 0 | 2121 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 2122 | | ServiceClientTracing.Enter(_invocationId, this, "ListModels", tracingParameters); |
| | 2123 | | } |
| | 2124 | | // Construct URL |
| 0 | 2125 | | var _baseUrl = Client.BaseUri; |
| 0 | 2126 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/models"; |
| 0 | 2127 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 2128 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 2129 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 2130 | | List<string> _queryParameters = new List<string>(); |
| 0 | 2131 | | if (skip != null) |
| | 2132 | | { |
| 0 | 2133 | | _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 2134 | | } |
| 0 | 2135 | | if (take != null) |
| | 2136 | | { |
| 0 | 2137 | | _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 2138 | | } |
| 0 | 2139 | | if (_queryParameters.Count > 0) |
| | 2140 | | { |
| 0 | 2141 | | _url += "?" + string.Join("&", _queryParameters); |
| | 2142 | | } |
| | 2143 | | // Create HTTP transport objects |
| 0 | 2144 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 2145 | | HttpResponseMessage _httpResponse = null; |
| 0 | 2146 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 2147 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 2148 | | // Set Headers |
| | 2149 | |
|
| | 2150 | |
|
| 0 | 2151 | | if (customHeaders != null) |
| | 2152 | | { |
| 0 | 2153 | | foreach(var _header in customHeaders) |
| | 2154 | | { |
| 0 | 2155 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 2156 | | { |
| 0 | 2157 | | _httpRequest.Headers.Remove(_header.Key); |
| | 2158 | | } |
| 0 | 2159 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 2160 | | } |
| | 2161 | | } |
| | 2162 | |
|
| | 2163 | | // Serialize Request |
| 0 | 2164 | | string _requestContent = null; |
| | 2165 | | // Set Credentials |
| 0 | 2166 | | if (Client.Credentials != null) |
| | 2167 | | { |
| 0 | 2168 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2169 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 2170 | | } |
| | 2171 | | // Send Request |
| 0 | 2172 | | if (_shouldTrace) |
| | 2173 | | { |
| 0 | 2174 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 2175 | | } |
| 0 | 2176 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2177 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 2178 | | if (_shouldTrace) |
| | 2179 | | { |
| 0 | 2180 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 2181 | | } |
| 0 | 2182 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 2183 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2184 | | string _responseContent = null; |
| 0 | 2185 | | if ((int)_statusCode != 200) |
| | 2186 | | { |
| 0 | 2187 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 2188 | | try |
| | 2189 | | { |
| 0 | 2190 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 2191 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 2192 | | if (_errorBody != null) |
| | 2193 | | { |
| 0 | 2194 | | ex.Body = _errorBody; |
| | 2195 | | } |
| 0 | 2196 | | } |
| 0 | 2197 | | catch (JsonException) |
| | 2198 | | { |
| | 2199 | | // Ignore the exception |
| 0 | 2200 | | } |
| 0 | 2201 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 2202 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 2203 | | if (_shouldTrace) |
| | 2204 | | { |
| 0 | 2205 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 2206 | | } |
| 0 | 2207 | | _httpRequest.Dispose(); |
| 0 | 2208 | | if (_httpResponse != null) |
| | 2209 | | { |
| 0 | 2210 | | _httpResponse.Dispose(); |
| | 2211 | | } |
| 0 | 2212 | | throw ex; |
| | 2213 | | } |
| | 2214 | | // Create Result |
| 0 | 2215 | | var _result = new HttpOperationResponse<IList<ModelInfoResponse>>(); |
| 0 | 2216 | | _result.Request = _httpRequest; |
| 0 | 2217 | | _result.Response = _httpResponse; |
| | 2218 | | // Deserialize Response |
| 0 | 2219 | | if ((int)_statusCode == 200) |
| | 2220 | | { |
| 0 | 2221 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 2222 | | try |
| | 2223 | | { |
| 0 | 2224 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<ModelInfoResponse>>(_respo |
| 0 | 2225 | | } |
| 0 | 2226 | | catch (JsonException ex) |
| | 2227 | | { |
| 0 | 2228 | | _httpRequest.Dispose(); |
| 0 | 2229 | | if (_httpResponse != null) |
| | 2230 | | { |
| 0 | 2231 | | _httpResponse.Dispose(); |
| | 2232 | | } |
| 0 | 2233 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 2234 | | } |
| | 2235 | | } |
| 0 | 2236 | | if (_shouldTrace) |
| | 2237 | | { |
| 0 | 2238 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 2239 | | } |
| 0 | 2240 | | return _result; |
| 0 | 2241 | | } |
| | 2242 | |
|
| | 2243 | | /// <summary> |
| | 2244 | | /// Gets the example utterances for the given intent or entity model in a |
| | 2245 | | /// version of the application. |
| | 2246 | | /// </summary> |
| | 2247 | | /// <param name='appId'> |
| | 2248 | | /// The application ID. |
| | 2249 | | /// </param> |
| | 2250 | | /// <param name='versionId'> |
| | 2251 | | /// The version ID. |
| | 2252 | | /// </param> |
| | 2253 | | /// <param name='modelId'> |
| | 2254 | | /// The ID (GUID) of the model. |
| | 2255 | | /// </param> |
| | 2256 | | /// <param name='skip'> |
| | 2257 | | /// The number of entries to skip. Default value is 0. |
| | 2258 | | /// </param> |
| | 2259 | | /// <param name='take'> |
| | 2260 | | /// The number of entries to return. Maximum page size is 500. Default is 100. |
| | 2261 | | /// </param> |
| | 2262 | | /// <param name='customHeaders'> |
| | 2263 | | /// Headers that will be added to request. |
| | 2264 | | /// </param> |
| | 2265 | | /// <param name='cancellationToken'> |
| | 2266 | | /// The cancellation token. |
| | 2267 | | /// </param> |
| | 2268 | | /// <exception cref="ErrorResponseException"> |
| | 2269 | | /// Thrown when the operation returned an invalid status code |
| | 2270 | | /// </exception> |
| | 2271 | | /// <exception cref="SerializationException"> |
| | 2272 | | /// Thrown when unable to deserialize the response |
| | 2273 | | /// </exception> |
| | 2274 | | /// <exception cref="ValidationException"> |
| | 2275 | | /// Thrown when a required parameter is null |
| | 2276 | | /// </exception> |
| | 2277 | | /// <exception cref="System.ArgumentNullException"> |
| | 2278 | | /// Thrown when a required parameter is null |
| | 2279 | | /// </exception> |
| | 2280 | | /// <return> |
| | 2281 | | /// A response object containing the response body and response headers. |
| | 2282 | | /// </return> |
| | 2283 | | public async Task<HttpOperationResponse<IList<LabelTextObject>>> ExamplesMethodWithHttpMessagesAsync(System.Guid |
| | 2284 | | { |
| 0 | 2285 | | if (Client.Endpoint == null) |
| | 2286 | | { |
| 0 | 2287 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 2288 | | } |
| 0 | 2289 | | if (versionId == null) |
| | 2290 | | { |
| 0 | 2291 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 2292 | | } |
| 0 | 2293 | | if (modelId == null) |
| | 2294 | | { |
| 0 | 2295 | | throw new ValidationException(ValidationRules.CannotBeNull, "modelId"); |
| | 2296 | | } |
| 0 | 2297 | | if (skip < 0) |
| | 2298 | | { |
| 0 | 2299 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0); |
| | 2300 | | } |
| 0 | 2301 | | if (take > 500) |
| | 2302 | | { |
| 0 | 2303 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500); |
| | 2304 | | } |
| 0 | 2305 | | if (take < 0) |
| | 2306 | | { |
| 0 | 2307 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0); |
| | 2308 | | } |
| | 2309 | | // Tracing |
| 0 | 2310 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 2311 | | string _invocationId = null; |
| 0 | 2312 | | if (_shouldTrace) |
| | 2313 | | { |
| 0 | 2314 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 2315 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 2316 | | tracingParameters.Add("appId", appId); |
| 0 | 2317 | | tracingParameters.Add("versionId", versionId); |
| 0 | 2318 | | tracingParameters.Add("modelId", modelId); |
| 0 | 2319 | | tracingParameters.Add("skip", skip); |
| 0 | 2320 | | tracingParameters.Add("take", take); |
| 0 | 2321 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 2322 | | ServiceClientTracing.Enter(_invocationId, this, "ExamplesMethod", tracingParameters); |
| | 2323 | | } |
| | 2324 | | // Construct URL |
| 0 | 2325 | | var _baseUrl = Client.BaseUri; |
| 0 | 2326 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/models/{model |
| 0 | 2327 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 2328 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 2329 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 2330 | | _url = _url.Replace("{modelId}", System.Uri.EscapeDataString(modelId)); |
| 0 | 2331 | | List<string> _queryParameters = new List<string>(); |
| 0 | 2332 | | if (skip != null) |
| | 2333 | | { |
| 0 | 2334 | | _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 2335 | | } |
| 0 | 2336 | | if (take != null) |
| | 2337 | | { |
| 0 | 2338 | | _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 2339 | | } |
| 0 | 2340 | | if (_queryParameters.Count > 0) |
| | 2341 | | { |
| 0 | 2342 | | _url += "?" + string.Join("&", _queryParameters); |
| | 2343 | | } |
| | 2344 | | // Create HTTP transport objects |
| 0 | 2345 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 2346 | | HttpResponseMessage _httpResponse = null; |
| 0 | 2347 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 2348 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 2349 | | // Set Headers |
| | 2350 | |
|
| | 2351 | |
|
| 0 | 2352 | | if (customHeaders != null) |
| | 2353 | | { |
| 0 | 2354 | | foreach(var _header in customHeaders) |
| | 2355 | | { |
| 0 | 2356 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 2357 | | { |
| 0 | 2358 | | _httpRequest.Headers.Remove(_header.Key); |
| | 2359 | | } |
| 0 | 2360 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 2361 | | } |
| | 2362 | | } |
| | 2363 | |
|
| | 2364 | | // Serialize Request |
| 0 | 2365 | | string _requestContent = null; |
| | 2366 | | // Set Credentials |
| 0 | 2367 | | if (Client.Credentials != null) |
| | 2368 | | { |
| 0 | 2369 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2370 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 2371 | | } |
| | 2372 | | // Send Request |
| 0 | 2373 | | if (_shouldTrace) |
| | 2374 | | { |
| 0 | 2375 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 2376 | | } |
| 0 | 2377 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2378 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 2379 | | if (_shouldTrace) |
| | 2380 | | { |
| 0 | 2381 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 2382 | | } |
| 0 | 2383 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 2384 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 2385 | | string _responseContent = null; |
| 0 | 2386 | | if ((int)_statusCode != 200) |
| | 2387 | | { |
| 0 | 2388 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 2389 | | try |
| | 2390 | | { |
| 0 | 2391 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 2392 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 2393 | | if (_errorBody != null) |
| | 2394 | | { |
| 0 | 2395 | | ex.Body = _errorBody; |
| | 2396 | | } |
| 0 | 2397 | | } |
| 0 | 2398 | | catch (JsonException) |
| | 2399 | | { |
| | 2400 | | // Ignore the exception |
| 0 | 2401 | | } |
| 0 | 2402 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 2403 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 2404 | | if (_shouldTrace) |
| | 2405 | | { |
| 0 | 2406 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 2407 | | } |
| 0 | 2408 | | _httpRequest.Dispose(); |
| 0 | 2409 | | if (_httpResponse != null) |
| | 2410 | | { |
| 0 | 2411 | | _httpResponse.Dispose(); |
| | 2412 | | } |
| 0 | 2413 | | throw ex; |
| | 2414 | | } |
| | 2415 | | // Create Result |
| 0 | 2416 | | var _result = new HttpOperationResponse<IList<LabelTextObject>>(); |
| 0 | 2417 | | _result.Request = _httpRequest; |
| 0 | 2418 | | _result.Response = _httpResponse; |
| | 2419 | | // Deserialize Response |
| 0 | 2420 | | if ((int)_statusCode == 200) |
| | 2421 | | { |
| 0 | 2422 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 2423 | | try |
| | 2424 | | { |
| 0 | 2425 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<LabelTextObject>>(_respons |
| 0 | 2426 | | } |
| 0 | 2427 | | catch (JsonException ex) |
| | 2428 | | { |
| 0 | 2429 | | _httpRequest.Dispose(); |
| 0 | 2430 | | if (_httpResponse != null) |
| | 2431 | | { |
| 0 | 2432 | | _httpResponse.Dispose(); |
| | 2433 | | } |
| 0 | 2434 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 2435 | | } |
| | 2436 | | } |
| 0 | 2437 | | if (_shouldTrace) |
| | 2438 | | { |
| 0 | 2439 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 2440 | | } |
| 0 | 2441 | | return _result; |
| 0 | 2442 | | } |
| | 2443 | |
|
| | 2444 | | /// <summary> |
| | 2445 | | /// Gets information about the intent model in a version of the application. |
| | 2446 | | /// </summary> |
| | 2447 | | /// <param name='appId'> |
| | 2448 | | /// The application ID. |
| | 2449 | | /// </param> |
| | 2450 | | /// <param name='versionId'> |
| | 2451 | | /// The version ID. |
| | 2452 | | /// </param> |
| | 2453 | | /// <param name='intentId'> |
| | 2454 | | /// The intent classifier ID. |
| | 2455 | | /// </param> |
| | 2456 | | /// <param name='customHeaders'> |
| | 2457 | | /// Headers that will be added to request. |
| | 2458 | | /// </param> |
| | 2459 | | /// <param name='cancellationToken'> |
| | 2460 | | /// The cancellation token. |
| | 2461 | | /// </param> |
| | 2462 | | /// <exception cref="ErrorResponseException"> |
| | 2463 | | /// Thrown when the operation returned an invalid status code |
| | 2464 | | /// </exception> |
| | 2465 | | /// <exception cref="SerializationException"> |
| | 2466 | | /// Thrown when unable to deserialize the response |
| | 2467 | | /// </exception> |
| | 2468 | | /// <exception cref="ValidationException"> |
| | 2469 | | /// Thrown when a required parameter is null |
| | 2470 | | /// </exception> |
| | 2471 | | /// <exception cref="System.ArgumentNullException"> |
| | 2472 | | /// Thrown when a required parameter is null |
| | 2473 | | /// </exception> |
| | 2474 | | /// <return> |
| | 2475 | | /// A response object containing the response body and response headers. |
| | 2476 | | /// </return> |
| | 2477 | | public async Task<HttpOperationResponse<IntentClassifier>> GetIntentWithHttpMessagesAsync(System.Guid appId, str |
| | 2478 | | { |
| 3 | 2479 | | if (Client.Endpoint == null) |
| | 2480 | | { |
| 0 | 2481 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 2482 | | } |
| 3 | 2483 | | if (versionId == null) |
| | 2484 | | { |
| 0 | 2485 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 2486 | | } |
| | 2487 | | // Tracing |
| 3 | 2488 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 3 | 2489 | | string _invocationId = null; |
| 3 | 2490 | | if (_shouldTrace) |
| | 2491 | | { |
| 0 | 2492 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 2493 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 2494 | | tracingParameters.Add("appId", appId); |
| 0 | 2495 | | tracingParameters.Add("versionId", versionId); |
| 0 | 2496 | | tracingParameters.Add("intentId", intentId); |
| 0 | 2497 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 2498 | | ServiceClientTracing.Enter(_invocationId, this, "GetIntent", tracingParameters); |
| | 2499 | | } |
| | 2500 | | // Construct URL |
| 3 | 2501 | | var _baseUrl = Client.BaseUri; |
| 3 | 2502 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte |
| 3 | 2503 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 3 | 2504 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 3 | 2505 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 3 | 2506 | | _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 2507 | | // Create HTTP transport objects |
| 3 | 2508 | | var _httpRequest = new HttpRequestMessage(); |
| 3 | 2509 | | HttpResponseMessage _httpResponse = null; |
| 3 | 2510 | | _httpRequest.Method = new HttpMethod("GET"); |
| 3 | 2511 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 2512 | | // Set Headers |
| | 2513 | |
|
| | 2514 | |
|
| 3 | 2515 | | if (customHeaders != null) |
| | 2516 | | { |
| 0 | 2517 | | foreach(var _header in customHeaders) |
| | 2518 | | { |
| 0 | 2519 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 2520 | | { |
| 0 | 2521 | | _httpRequest.Headers.Remove(_header.Key); |
| | 2522 | | } |
| 0 | 2523 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 2524 | | } |
| | 2525 | | } |
| | 2526 | |
|
| | 2527 | | // Serialize Request |
| 3 | 2528 | | string _requestContent = null; |
| | 2529 | | // Set Credentials |
| 3 | 2530 | | if (Client.Credentials != null) |
| | 2531 | | { |
| 3 | 2532 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 2533 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 2534 | | } |
| | 2535 | | // Send Request |
| 3 | 2536 | | if (_shouldTrace) |
| | 2537 | | { |
| 0 | 2538 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 2539 | | } |
| 3 | 2540 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 2541 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 3 | 2542 | | if (_shouldTrace) |
| | 2543 | | { |
| 0 | 2544 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 2545 | | } |
| 3 | 2546 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 3 | 2547 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 2548 | | string _responseContent = null; |
| 3 | 2549 | | if ((int)_statusCode != 200) |
| | 2550 | | { |
| 0 | 2551 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 2552 | | try |
| | 2553 | | { |
| 0 | 2554 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 2555 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 2556 | | if (_errorBody != null) |
| | 2557 | | { |
| 0 | 2558 | | ex.Body = _errorBody; |
| | 2559 | | } |
| 0 | 2560 | | } |
| 0 | 2561 | | catch (JsonException) |
| | 2562 | | { |
| | 2563 | | // Ignore the exception |
| 0 | 2564 | | } |
| 0 | 2565 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 2566 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 2567 | | if (_shouldTrace) |
| | 2568 | | { |
| 0 | 2569 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 2570 | | } |
| 0 | 2571 | | _httpRequest.Dispose(); |
| 0 | 2572 | | if (_httpResponse != null) |
| | 2573 | | { |
| 0 | 2574 | | _httpResponse.Dispose(); |
| | 2575 | | } |
| 0 | 2576 | | throw ex; |
| | 2577 | | } |
| | 2578 | | // Create Result |
| 3 | 2579 | | var _result = new HttpOperationResponse<IntentClassifier>(); |
| 3 | 2580 | | _result.Request = _httpRequest; |
| 3 | 2581 | | _result.Response = _httpResponse; |
| | 2582 | | // Deserialize Response |
| 3 | 2583 | | if ((int)_statusCode == 200) |
| | 2584 | | { |
| 3 | 2585 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 2586 | | try |
| | 2587 | | { |
| 3 | 2588 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IntentClassifier>(_responseConte |
| 3 | 2589 | | } |
| 0 | 2590 | | catch (JsonException ex) |
| | 2591 | | { |
| 0 | 2592 | | _httpRequest.Dispose(); |
| 0 | 2593 | | if (_httpResponse != null) |
| | 2594 | | { |
| 0 | 2595 | | _httpResponse.Dispose(); |
| | 2596 | | } |
| 0 | 2597 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 2598 | | } |
| | 2599 | | } |
| 3 | 2600 | | if (_shouldTrace) |
| | 2601 | | { |
| 0 | 2602 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 2603 | | } |
| 3 | 2604 | | return _result; |
| 3 | 2605 | | } |
| | 2606 | |
|
| | 2607 | | /// <summary> |
| | 2608 | | /// Updates the name of an intent in a version of the application. |
| | 2609 | | /// </summary> |
| | 2610 | | /// <param name='appId'> |
| | 2611 | | /// The application ID. |
| | 2612 | | /// </param> |
| | 2613 | | /// <param name='versionId'> |
| | 2614 | | /// The version ID. |
| | 2615 | | /// </param> |
| | 2616 | | /// <param name='intentId'> |
| | 2617 | | /// The intent classifier ID. |
| | 2618 | | /// </param> |
| | 2619 | | /// <param name='modelUpdateObject'> |
| | 2620 | | /// A model object containing the new intent name. |
| | 2621 | | /// </param> |
| | 2622 | | /// <param name='customHeaders'> |
| | 2623 | | /// Headers that will be added to request. |
| | 2624 | | /// </param> |
| | 2625 | | /// <param name='cancellationToken'> |
| | 2626 | | /// The cancellation token. |
| | 2627 | | /// </param> |
| | 2628 | | /// <exception cref="ErrorResponseException"> |
| | 2629 | | /// Thrown when the operation returned an invalid status code |
| | 2630 | | /// </exception> |
| | 2631 | | /// <exception cref="SerializationException"> |
| | 2632 | | /// Thrown when unable to deserialize the response |
| | 2633 | | /// </exception> |
| | 2634 | | /// <exception cref="ValidationException"> |
| | 2635 | | /// Thrown when a required parameter is null |
| | 2636 | | /// </exception> |
| | 2637 | | /// <exception cref="System.ArgumentNullException"> |
| | 2638 | | /// Thrown when a required parameter is null |
| | 2639 | | /// </exception> |
| | 2640 | | /// <return> |
| | 2641 | | /// A response object containing the response body and response headers. |
| | 2642 | | /// </return> |
| | 2643 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateIntentWithHttpMessagesAsync(System.Guid appId, s |
| | 2644 | | { |
| 1 | 2645 | | if (Client.Endpoint == null) |
| | 2646 | | { |
| 0 | 2647 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 2648 | | } |
| 1 | 2649 | | if (versionId == null) |
| | 2650 | | { |
| 0 | 2651 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 2652 | | } |
| 1 | 2653 | | if (modelUpdateObject == null) |
| | 2654 | | { |
| 0 | 2655 | | throw new ValidationException(ValidationRules.CannotBeNull, "modelUpdateObject"); |
| | 2656 | | } |
| | 2657 | | // Tracing |
| 1 | 2658 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 2659 | | string _invocationId = null; |
| 1 | 2660 | | if (_shouldTrace) |
| | 2661 | | { |
| 0 | 2662 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 2663 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 2664 | | tracingParameters.Add("appId", appId); |
| 0 | 2665 | | tracingParameters.Add("versionId", versionId); |
| 0 | 2666 | | tracingParameters.Add("intentId", intentId); |
| 0 | 2667 | | tracingParameters.Add("modelUpdateObject", modelUpdateObject); |
| 0 | 2668 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 2669 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateIntent", tracingParameters); |
| | 2670 | | } |
| | 2671 | | // Construct URL |
| 1 | 2672 | | var _baseUrl = Client.BaseUri; |
| 1 | 2673 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte |
| 1 | 2674 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 2675 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 2676 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 2677 | | _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 2678 | | // Create HTTP transport objects |
| 1 | 2679 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 2680 | | HttpResponseMessage _httpResponse = null; |
| 1 | 2681 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 1 | 2682 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 2683 | | // Set Headers |
| | 2684 | |
|
| | 2685 | |
|
| 1 | 2686 | | if (customHeaders != null) |
| | 2687 | | { |
| 0 | 2688 | | foreach(var _header in customHeaders) |
| | 2689 | | { |
| 0 | 2690 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 2691 | | { |
| 0 | 2692 | | _httpRequest.Headers.Remove(_header.Key); |
| | 2693 | | } |
| 0 | 2694 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 2695 | | } |
| | 2696 | | } |
| | 2697 | |
|
| | 2698 | | // Serialize Request |
| 1 | 2699 | | string _requestContent = null; |
| 1 | 2700 | | if(modelUpdateObject != null) |
| | 2701 | | { |
| 1 | 2702 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(modelUpdateObject, Client.Serializa |
| 1 | 2703 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 2704 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 2705 | | } |
| | 2706 | | // Set Credentials |
| 1 | 2707 | | if (Client.Credentials != null) |
| | 2708 | | { |
| 1 | 2709 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 2710 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 2711 | | } |
| | 2712 | | // Send Request |
| 1 | 2713 | | if (_shouldTrace) |
| | 2714 | | { |
| 0 | 2715 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 2716 | | } |
| 1 | 2717 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 2718 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 2719 | | if (_shouldTrace) |
| | 2720 | | { |
| 0 | 2721 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 2722 | | } |
| 1 | 2723 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 2724 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 2725 | | string _responseContent = null; |
| 1 | 2726 | | if ((int)_statusCode != 200) |
| | 2727 | | { |
| 0 | 2728 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 2729 | | try |
| | 2730 | | { |
| 0 | 2731 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 2732 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 2733 | | if (_errorBody != null) |
| | 2734 | | { |
| 0 | 2735 | | ex.Body = _errorBody; |
| | 2736 | | } |
| 0 | 2737 | | } |
| 0 | 2738 | | catch (JsonException) |
| | 2739 | | { |
| | 2740 | | // Ignore the exception |
| 0 | 2741 | | } |
| 0 | 2742 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 2743 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 2744 | | if (_shouldTrace) |
| | 2745 | | { |
| 0 | 2746 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 2747 | | } |
| 0 | 2748 | | _httpRequest.Dispose(); |
| 0 | 2749 | | if (_httpResponse != null) |
| | 2750 | | { |
| 0 | 2751 | | _httpResponse.Dispose(); |
| | 2752 | | } |
| 0 | 2753 | | throw ex; |
| | 2754 | | } |
| | 2755 | | // Create Result |
| 1 | 2756 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 2757 | | _result.Request = _httpRequest; |
| 1 | 2758 | | _result.Response = _httpResponse; |
| | 2759 | | // Deserialize Response |
| 1 | 2760 | | if ((int)_statusCode == 200) |
| | 2761 | | { |
| 1 | 2762 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 2763 | | try |
| | 2764 | | { |
| 1 | 2765 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 2766 | | } |
| 0 | 2767 | | catch (JsonException ex) |
| | 2768 | | { |
| 0 | 2769 | | _httpRequest.Dispose(); |
| 0 | 2770 | | if (_httpResponse != null) |
| | 2771 | | { |
| 0 | 2772 | | _httpResponse.Dispose(); |
| | 2773 | | } |
| 0 | 2774 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 2775 | | } |
| | 2776 | | } |
| 1 | 2777 | | if (_shouldTrace) |
| | 2778 | | { |
| 0 | 2779 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 2780 | | } |
| 1 | 2781 | | return _result; |
| 1 | 2782 | | } |
| | 2783 | |
|
| | 2784 | | /// <summary> |
| | 2785 | | /// Deletes an intent from a version of the application. |
| | 2786 | | /// </summary> |
| | 2787 | | /// <param name='appId'> |
| | 2788 | | /// The application ID. |
| | 2789 | | /// </param> |
| | 2790 | | /// <param name='versionId'> |
| | 2791 | | /// The version ID. |
| | 2792 | | /// </param> |
| | 2793 | | /// <param name='intentId'> |
| | 2794 | | /// The intent classifier ID. |
| | 2795 | | /// </param> |
| | 2796 | | /// <param name='deleteUtterances'> |
| | 2797 | | /// If true, deletes the intent's example utterances. If false, moves the |
| | 2798 | | /// example utterances to the None intent. The default value is false. |
| | 2799 | | /// </param> |
| | 2800 | | /// <param name='customHeaders'> |
| | 2801 | | /// Headers that will be added to request. |
| | 2802 | | /// </param> |
| | 2803 | | /// <param name='cancellationToken'> |
| | 2804 | | /// The cancellation token. |
| | 2805 | | /// </param> |
| | 2806 | | /// <exception cref="ErrorResponseException"> |
| | 2807 | | /// Thrown when the operation returned an invalid status code |
| | 2808 | | /// </exception> |
| | 2809 | | /// <exception cref="SerializationException"> |
| | 2810 | | /// Thrown when unable to deserialize the response |
| | 2811 | | /// </exception> |
| | 2812 | | /// <exception cref="ValidationException"> |
| | 2813 | | /// Thrown when a required parameter is null |
| | 2814 | | /// </exception> |
| | 2815 | | /// <exception cref="System.ArgumentNullException"> |
| | 2816 | | /// Thrown when a required parameter is null |
| | 2817 | | /// </exception> |
| | 2818 | | /// <return> |
| | 2819 | | /// A response object containing the response body and response headers. |
| | 2820 | | /// </return> |
| | 2821 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteIntentWithHttpMessagesAsync(System.Guid appId, s |
| | 2822 | | { |
| 9 | 2823 | | if (Client.Endpoint == null) |
| | 2824 | | { |
| 0 | 2825 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 2826 | | } |
| 9 | 2827 | | if (versionId == null) |
| | 2828 | | { |
| 0 | 2829 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 2830 | | } |
| | 2831 | | // Tracing |
| 9 | 2832 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 9 | 2833 | | string _invocationId = null; |
| 9 | 2834 | | if (_shouldTrace) |
| | 2835 | | { |
| 0 | 2836 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 2837 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 2838 | | tracingParameters.Add("appId", appId); |
| 0 | 2839 | | tracingParameters.Add("versionId", versionId); |
| 0 | 2840 | | tracingParameters.Add("intentId", intentId); |
| 0 | 2841 | | tracingParameters.Add("deleteUtterances", deleteUtterances); |
| 0 | 2842 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 2843 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteIntent", tracingParameters); |
| | 2844 | | } |
| | 2845 | | // Construct URL |
| 9 | 2846 | | var _baseUrl = Client.BaseUri; |
| 9 | 2847 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte |
| 9 | 2848 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 9 | 2849 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 9 | 2850 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 9 | 2851 | | _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 9 | 2852 | | List<string> _queryParameters = new List<string>(); |
| 9 | 2853 | | if (deleteUtterances != null) |
| | 2854 | | { |
| 9 | 2855 | | _queryParameters.Add(string.Format("deleteUtterances={0}", System.Uri.EscapeDataString(Rest.Serializatio |
| | 2856 | | } |
| 9 | 2857 | | if (_queryParameters.Count > 0) |
| | 2858 | | { |
| 9 | 2859 | | _url += "?" + string.Join("&", _queryParameters); |
| | 2860 | | } |
| | 2861 | | // Create HTTP transport objects |
| 9 | 2862 | | var _httpRequest = new HttpRequestMessage(); |
| 9 | 2863 | | HttpResponseMessage _httpResponse = null; |
| 9 | 2864 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 9 | 2865 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 2866 | | // Set Headers |
| | 2867 | |
|
| | 2868 | |
|
| 9 | 2869 | | if (customHeaders != null) |
| | 2870 | | { |
| 0 | 2871 | | foreach(var _header in customHeaders) |
| | 2872 | | { |
| 0 | 2873 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 2874 | | { |
| 0 | 2875 | | _httpRequest.Headers.Remove(_header.Key); |
| | 2876 | | } |
| 0 | 2877 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 2878 | | } |
| | 2879 | | } |
| | 2880 | |
|
| | 2881 | | // Serialize Request |
| 9 | 2882 | | string _requestContent = null; |
| | 2883 | | // Set Credentials |
| 9 | 2884 | | if (Client.Credentials != null) |
| | 2885 | | { |
| 9 | 2886 | | cancellationToken.ThrowIfCancellationRequested(); |
| 9 | 2887 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 2888 | | } |
| | 2889 | | // Send Request |
| 9 | 2890 | | if (_shouldTrace) |
| | 2891 | | { |
| 0 | 2892 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 2893 | | } |
| 9 | 2894 | | cancellationToken.ThrowIfCancellationRequested(); |
| 9 | 2895 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 9 | 2896 | | if (_shouldTrace) |
| | 2897 | | { |
| 0 | 2898 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 2899 | | } |
| 9 | 2900 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 9 | 2901 | | cancellationToken.ThrowIfCancellationRequested(); |
| 9 | 2902 | | string _responseContent = null; |
| 9 | 2903 | | if ((int)_statusCode != 200) |
| | 2904 | | { |
| 0 | 2905 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 2906 | | try |
| | 2907 | | { |
| 0 | 2908 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 2909 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 2910 | | if (_errorBody != null) |
| | 2911 | | { |
| 0 | 2912 | | ex.Body = _errorBody; |
| | 2913 | | } |
| 0 | 2914 | | } |
| 0 | 2915 | | catch (JsonException) |
| | 2916 | | { |
| | 2917 | | // Ignore the exception |
| 0 | 2918 | | } |
| 0 | 2919 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 2920 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 2921 | | if (_shouldTrace) |
| | 2922 | | { |
| 0 | 2923 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 2924 | | } |
| 0 | 2925 | | _httpRequest.Dispose(); |
| 0 | 2926 | | if (_httpResponse != null) |
| | 2927 | | { |
| 0 | 2928 | | _httpResponse.Dispose(); |
| | 2929 | | } |
| 0 | 2930 | | throw ex; |
| | 2931 | | } |
| | 2932 | | // Create Result |
| 9 | 2933 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 9 | 2934 | | _result.Request = _httpRequest; |
| 9 | 2935 | | _result.Response = _httpResponse; |
| | 2936 | | // Deserialize Response |
| 9 | 2937 | | if ((int)_statusCode == 200) |
| | 2938 | | { |
| 9 | 2939 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 2940 | | try |
| | 2941 | | { |
| 9 | 2942 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 9 | 2943 | | } |
| 0 | 2944 | | catch (JsonException ex) |
| | 2945 | | { |
| 0 | 2946 | | _httpRequest.Dispose(); |
| 0 | 2947 | | if (_httpResponse != null) |
| | 2948 | | { |
| 0 | 2949 | | _httpResponse.Dispose(); |
| | 2950 | | } |
| 0 | 2951 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 2952 | | } |
| | 2953 | | } |
| 9 | 2954 | | if (_shouldTrace) |
| | 2955 | | { |
| 0 | 2956 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 2957 | | } |
| 9 | 2958 | | return _result; |
| 9 | 2959 | | } |
| | 2960 | |
|
| | 2961 | | /// <summary> |
| | 2962 | | /// Gets information about an entity model in a version of the application. |
| | 2963 | | /// </summary> |
| | 2964 | | /// <param name='appId'> |
| | 2965 | | /// The application ID. |
| | 2966 | | /// </param> |
| | 2967 | | /// <param name='versionId'> |
| | 2968 | | /// The version ID. |
| | 2969 | | /// </param> |
| | 2970 | | /// <param name='entityId'> |
| | 2971 | | /// The entity extractor ID. |
| | 2972 | | /// </param> |
| | 2973 | | /// <param name='customHeaders'> |
| | 2974 | | /// Headers that will be added to request. |
| | 2975 | | /// </param> |
| | 2976 | | /// <param name='cancellationToken'> |
| | 2977 | | /// The cancellation token. |
| | 2978 | | /// </param> |
| | 2979 | | /// <exception cref="ErrorResponseException"> |
| | 2980 | | /// Thrown when the operation returned an invalid status code |
| | 2981 | | /// </exception> |
| | 2982 | | /// <exception cref="SerializationException"> |
| | 2983 | | /// Thrown when unable to deserialize the response |
| | 2984 | | /// </exception> |
| | 2985 | | /// <exception cref="ValidationException"> |
| | 2986 | | /// Thrown when a required parameter is null |
| | 2987 | | /// </exception> |
| | 2988 | | /// <exception cref="System.ArgumentNullException"> |
| | 2989 | | /// Thrown when a required parameter is null |
| | 2990 | | /// </exception> |
| | 2991 | | /// <return> |
| | 2992 | | /// A response object containing the response body and response headers. |
| | 2993 | | /// </return> |
| | 2994 | | public async Task<HttpOperationResponse<NDepthEntityExtractor>> GetEntityWithHttpMessagesAsync(System.Guid appId |
| | 2995 | | { |
| 10 | 2996 | | if (Client.Endpoint == null) |
| | 2997 | | { |
| 0 | 2998 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 2999 | | } |
| 10 | 3000 | | if (versionId == null) |
| | 3001 | | { |
| 0 | 3002 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 3003 | | } |
| | 3004 | | // Tracing |
| 10 | 3005 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 10 | 3006 | | string _invocationId = null; |
| 10 | 3007 | | if (_shouldTrace) |
| | 3008 | | { |
| 0 | 3009 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 3010 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 3011 | | tracingParameters.Add("appId", appId); |
| 0 | 3012 | | tracingParameters.Add("versionId", versionId); |
| 0 | 3013 | | tracingParameters.Add("entityId", entityId); |
| 0 | 3014 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 3015 | | ServiceClientTracing.Enter(_invocationId, this, "GetEntity", tracingParameters); |
| | 3016 | | } |
| | 3017 | | // Construct URL |
| 10 | 3018 | | var _baseUrl = Client.BaseUri; |
| 10 | 3019 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent |
| 10 | 3020 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 10 | 3021 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 10 | 3022 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 10 | 3023 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 3024 | | // Create HTTP transport objects |
| 10 | 3025 | | var _httpRequest = new HttpRequestMessage(); |
| 10 | 3026 | | HttpResponseMessage _httpResponse = null; |
| 10 | 3027 | | _httpRequest.Method = new HttpMethod("GET"); |
| 10 | 3028 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 3029 | | // Set Headers |
| | 3030 | |
|
| | 3031 | |
|
| 10 | 3032 | | if (customHeaders != null) |
| | 3033 | | { |
| 0 | 3034 | | foreach(var _header in customHeaders) |
| | 3035 | | { |
| 0 | 3036 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 3037 | | { |
| 0 | 3038 | | _httpRequest.Headers.Remove(_header.Key); |
| | 3039 | | } |
| 0 | 3040 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 3041 | | } |
| | 3042 | | } |
| | 3043 | |
|
| | 3044 | | // Serialize Request |
| 10 | 3045 | | string _requestContent = null; |
| | 3046 | | // Set Credentials |
| 10 | 3047 | | if (Client.Credentials != null) |
| | 3048 | | { |
| 10 | 3049 | | cancellationToken.ThrowIfCancellationRequested(); |
| 10 | 3050 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 3051 | | } |
| | 3052 | | // Send Request |
| 10 | 3053 | | if (_shouldTrace) |
| | 3054 | | { |
| 0 | 3055 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 3056 | | } |
| 10 | 3057 | | cancellationToken.ThrowIfCancellationRequested(); |
| 10 | 3058 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 10 | 3059 | | if (_shouldTrace) |
| | 3060 | | { |
| 0 | 3061 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 3062 | | } |
| 10 | 3063 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 10 | 3064 | | cancellationToken.ThrowIfCancellationRequested(); |
| 10 | 3065 | | string _responseContent = null; |
| 10 | 3066 | | if ((int)_statusCode != 200) |
| | 3067 | | { |
| 0 | 3068 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 3069 | | try |
| | 3070 | | { |
| 0 | 3071 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 3072 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 3073 | | if (_errorBody != null) |
| | 3074 | | { |
| 0 | 3075 | | ex.Body = _errorBody; |
| | 3076 | | } |
| 0 | 3077 | | } |
| 0 | 3078 | | catch (JsonException) |
| | 3079 | | { |
| | 3080 | | // Ignore the exception |
| 0 | 3081 | | } |
| 0 | 3082 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 3083 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 3084 | | if (_shouldTrace) |
| | 3085 | | { |
| 0 | 3086 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 3087 | | } |
| 0 | 3088 | | _httpRequest.Dispose(); |
| 0 | 3089 | | if (_httpResponse != null) |
| | 3090 | | { |
| 0 | 3091 | | _httpResponse.Dispose(); |
| | 3092 | | } |
| 0 | 3093 | | throw ex; |
| | 3094 | | } |
| | 3095 | | // Create Result |
| 10 | 3096 | | var _result = new HttpOperationResponse<NDepthEntityExtractor>(); |
| 10 | 3097 | | _result.Request = _httpRequest; |
| 10 | 3098 | | _result.Response = _httpResponse; |
| | 3099 | | // Deserialize Response |
| 10 | 3100 | | if ((int)_statusCode == 200) |
| | 3101 | | { |
| 10 | 3102 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 3103 | | try |
| | 3104 | | { |
| 10 | 3105 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<NDepthEntityExtractor>(_response |
| 10 | 3106 | | } |
| 0 | 3107 | | catch (JsonException ex) |
| | 3108 | | { |
| 0 | 3109 | | _httpRequest.Dispose(); |
| 0 | 3110 | | if (_httpResponse != null) |
| | 3111 | | { |
| 0 | 3112 | | _httpResponse.Dispose(); |
| | 3113 | | } |
| 0 | 3114 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 3115 | | } |
| | 3116 | | } |
| 10 | 3117 | | if (_shouldTrace) |
| | 3118 | | { |
| 0 | 3119 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 3120 | | } |
| 10 | 3121 | | return _result; |
| 10 | 3122 | | } |
| | 3123 | |
|
| | 3124 | | /// <summary> |
| | 3125 | | /// Deletes an entity or a child from a version of the application. |
| | 3126 | | /// </summary> |
| | 3127 | | /// <param name='appId'> |
| | 3128 | | /// The application ID. |
| | 3129 | | /// </param> |
| | 3130 | | /// <param name='versionId'> |
| | 3131 | | /// The version ID. |
| | 3132 | | /// </param> |
| | 3133 | | /// <param name='entityId'> |
| | 3134 | | /// The entity extractor or the child entity extractor ID. |
| | 3135 | | /// </param> |
| | 3136 | | /// <param name='customHeaders'> |
| | 3137 | | /// Headers that will be added to request. |
| | 3138 | | /// </param> |
| | 3139 | | /// <param name='cancellationToken'> |
| | 3140 | | /// The cancellation token. |
| | 3141 | | /// </param> |
| | 3142 | | /// <exception cref="ErrorResponseException"> |
| | 3143 | | /// Thrown when the operation returned an invalid status code |
| | 3144 | | /// </exception> |
| | 3145 | | /// <exception cref="SerializationException"> |
| | 3146 | | /// Thrown when unable to deserialize the response |
| | 3147 | | /// </exception> |
| | 3148 | | /// <exception cref="ValidationException"> |
| | 3149 | | /// Thrown when a required parameter is null |
| | 3150 | | /// </exception> |
| | 3151 | | /// <exception cref="System.ArgumentNullException"> |
| | 3152 | | /// Thrown when a required parameter is null |
| | 3153 | | /// </exception> |
| | 3154 | | /// <return> |
| | 3155 | | /// A response object containing the response body and response headers. |
| | 3156 | | /// </return> |
| | 3157 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteEntityWithHttpMessagesAsync(System.Guid appId, s |
| | 3158 | | { |
| 35 | 3159 | | if (Client.Endpoint == null) |
| | 3160 | | { |
| 0 | 3161 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 3162 | | } |
| 35 | 3163 | | if (versionId == null) |
| | 3164 | | { |
| 0 | 3165 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 3166 | | } |
| | 3167 | | // Tracing |
| 35 | 3168 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 35 | 3169 | | string _invocationId = null; |
| 35 | 3170 | | if (_shouldTrace) |
| | 3171 | | { |
| 0 | 3172 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 3173 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 3174 | | tracingParameters.Add("appId", appId); |
| 0 | 3175 | | tracingParameters.Add("versionId", versionId); |
| 0 | 3176 | | tracingParameters.Add("entityId", entityId); |
| 0 | 3177 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 3178 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteEntity", tracingParameters); |
| | 3179 | | } |
| | 3180 | | // Construct URL |
| 35 | 3181 | | var _baseUrl = Client.BaseUri; |
| 35 | 3182 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent |
| 35 | 3183 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 35 | 3184 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 35 | 3185 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 35 | 3186 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 3187 | | // Create HTTP transport objects |
| 35 | 3188 | | var _httpRequest = new HttpRequestMessage(); |
| 35 | 3189 | | HttpResponseMessage _httpResponse = null; |
| 35 | 3190 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 35 | 3191 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 3192 | | // Set Headers |
| | 3193 | |
|
| | 3194 | |
|
| 35 | 3195 | | if (customHeaders != null) |
| | 3196 | | { |
| 0 | 3197 | | foreach(var _header in customHeaders) |
| | 3198 | | { |
| 0 | 3199 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 3200 | | { |
| 0 | 3201 | | _httpRequest.Headers.Remove(_header.Key); |
| | 3202 | | } |
| 0 | 3203 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 3204 | | } |
| | 3205 | | } |
| | 3206 | |
|
| | 3207 | | // Serialize Request |
| 35 | 3208 | | string _requestContent = null; |
| | 3209 | | // Set Credentials |
| 35 | 3210 | | if (Client.Credentials != null) |
| | 3211 | | { |
| 35 | 3212 | | cancellationToken.ThrowIfCancellationRequested(); |
| 35 | 3213 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 3214 | | } |
| | 3215 | | // Send Request |
| 35 | 3216 | | if (_shouldTrace) |
| | 3217 | | { |
| 0 | 3218 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 3219 | | } |
| 35 | 3220 | | cancellationToken.ThrowIfCancellationRequested(); |
| 35 | 3221 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 35 | 3222 | | if (_shouldTrace) |
| | 3223 | | { |
| 0 | 3224 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 3225 | | } |
| 35 | 3226 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 35 | 3227 | | cancellationToken.ThrowIfCancellationRequested(); |
| 35 | 3228 | | string _responseContent = null; |
| 35 | 3229 | | if ((int)_statusCode != 200) |
| | 3230 | | { |
| 0 | 3231 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 3232 | | try |
| | 3233 | | { |
| 0 | 3234 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 3235 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 3236 | | if (_errorBody != null) |
| | 3237 | | { |
| 0 | 3238 | | ex.Body = _errorBody; |
| | 3239 | | } |
| 0 | 3240 | | } |
| 0 | 3241 | | catch (JsonException) |
| | 3242 | | { |
| | 3243 | | // Ignore the exception |
| 0 | 3244 | | } |
| 0 | 3245 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 3246 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 3247 | | if (_shouldTrace) |
| | 3248 | | { |
| 0 | 3249 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 3250 | | } |
| 0 | 3251 | | _httpRequest.Dispose(); |
| 0 | 3252 | | if (_httpResponse != null) |
| | 3253 | | { |
| 0 | 3254 | | _httpResponse.Dispose(); |
| | 3255 | | } |
| 0 | 3256 | | throw ex; |
| | 3257 | | } |
| | 3258 | | // Create Result |
| 35 | 3259 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 35 | 3260 | | _result.Request = _httpRequest; |
| 35 | 3261 | | _result.Response = _httpResponse; |
| | 3262 | | // Deserialize Response |
| 35 | 3263 | | if ((int)_statusCode == 200) |
| | 3264 | | { |
| 35 | 3265 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 3266 | | try |
| | 3267 | | { |
| 35 | 3268 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 35 | 3269 | | } |
| 0 | 3270 | | catch (JsonException ex) |
| | 3271 | | { |
| 0 | 3272 | | _httpRequest.Dispose(); |
| 0 | 3273 | | if (_httpResponse != null) |
| | 3274 | | { |
| 0 | 3275 | | _httpResponse.Dispose(); |
| | 3276 | | } |
| 0 | 3277 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 3278 | | } |
| | 3279 | | } |
| 35 | 3280 | | if (_shouldTrace) |
| | 3281 | | { |
| 0 | 3282 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 3283 | | } |
| 35 | 3284 | | return _result; |
| 35 | 3285 | | } |
| | 3286 | |
|
| | 3287 | | /// <summary> |
| | 3288 | | /// Updates the name of an entity extractor or the name and instanceOf model of |
| | 3289 | | /// a child entity extractor. |
| | 3290 | | /// </summary> |
| | 3291 | | /// <param name='appId'> |
| | 3292 | | /// The application ID. |
| | 3293 | | /// </param> |
| | 3294 | | /// <param name='versionId'> |
| | 3295 | | /// The version ID. |
| | 3296 | | /// </param> |
| | 3297 | | /// <param name='entityId'> |
| | 3298 | | /// The entity extractor or the child entity extractor ID. |
| | 3299 | | /// </param> |
| | 3300 | | /// <param name='entityModelUpdateObject'> |
| | 3301 | | /// A model object containing the name new entity extractor or the name and |
| | 3302 | | /// instance of model of a child entity extractor |
| | 3303 | | /// </param> |
| | 3304 | | /// <param name='customHeaders'> |
| | 3305 | | /// Headers that will be added to request. |
| | 3306 | | /// </param> |
| | 3307 | | /// <param name='cancellationToken'> |
| | 3308 | | /// The cancellation token. |
| | 3309 | | /// </param> |
| | 3310 | | /// <exception cref="ErrorResponseException"> |
| | 3311 | | /// Thrown when the operation returned an invalid status code |
| | 3312 | | /// </exception> |
| | 3313 | | /// <exception cref="SerializationException"> |
| | 3314 | | /// Thrown when unable to deserialize the response |
| | 3315 | | /// </exception> |
| | 3316 | | /// <exception cref="ValidationException"> |
| | 3317 | | /// Thrown when a required parameter is null |
| | 3318 | | /// </exception> |
| | 3319 | | /// <exception cref="System.ArgumentNullException"> |
| | 3320 | | /// Thrown when a required parameter is null |
| | 3321 | | /// </exception> |
| | 3322 | | /// <return> |
| | 3323 | | /// A response object containing the response body and response headers. |
| | 3324 | | /// </return> |
| | 3325 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateEntityChildWithHttpMessagesAsync(System.Guid app |
| | 3326 | | { |
| 3 | 3327 | | if (Client.Endpoint == null) |
| | 3328 | | { |
| 0 | 3329 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 3330 | | } |
| 3 | 3331 | | if (versionId == null) |
| | 3332 | | { |
| 0 | 3333 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 3334 | | } |
| 3 | 3335 | | if (entityModelUpdateObject == null) |
| | 3336 | | { |
| 0 | 3337 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityModelUpdateObject"); |
| | 3338 | | } |
| | 3339 | | // Tracing |
| 3 | 3340 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 3 | 3341 | | string _invocationId = null; |
| 3 | 3342 | | if (_shouldTrace) |
| | 3343 | | { |
| 0 | 3344 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 3345 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 3346 | | tracingParameters.Add("appId", appId); |
| 0 | 3347 | | tracingParameters.Add("versionId", versionId); |
| 0 | 3348 | | tracingParameters.Add("entityId", entityId); |
| 0 | 3349 | | tracingParameters.Add("entityModelUpdateObject", entityModelUpdateObject); |
| 0 | 3350 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 3351 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateEntityChild", tracingParameters); |
| | 3352 | | } |
| | 3353 | | // Construct URL |
| 3 | 3354 | | var _baseUrl = Client.BaseUri; |
| 3 | 3355 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent |
| 3 | 3356 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 3 | 3357 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 3 | 3358 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 3 | 3359 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 3360 | | // Create HTTP transport objects |
| 3 | 3361 | | var _httpRequest = new HttpRequestMessage(); |
| 3 | 3362 | | HttpResponseMessage _httpResponse = null; |
| 3 | 3363 | | _httpRequest.Method = new HttpMethod("PATCH"); |
| 3 | 3364 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 3365 | | // Set Headers |
| | 3366 | |
|
| | 3367 | |
|
| 3 | 3368 | | if (customHeaders != null) |
| | 3369 | | { |
| 0 | 3370 | | foreach(var _header in customHeaders) |
| | 3371 | | { |
| 0 | 3372 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 3373 | | { |
| 0 | 3374 | | _httpRequest.Headers.Remove(_header.Key); |
| | 3375 | | } |
| 0 | 3376 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 3377 | | } |
| | 3378 | | } |
| | 3379 | |
|
| | 3380 | | // Serialize Request |
| 3 | 3381 | | string _requestContent = null; |
| 3 | 3382 | | if(entityModelUpdateObject != null) |
| | 3383 | | { |
| 3 | 3384 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityModelUpdateObject, Client.Ser |
| 3 | 3385 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 3 | 3386 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 3387 | | } |
| | 3388 | | // Set Credentials |
| 3 | 3389 | | if (Client.Credentials != null) |
| | 3390 | | { |
| 3 | 3391 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 3392 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 3393 | | } |
| | 3394 | | // Send Request |
| 3 | 3395 | | if (_shouldTrace) |
| | 3396 | | { |
| 0 | 3397 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 3398 | | } |
| 3 | 3399 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 3400 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 3 | 3401 | | if (_shouldTrace) |
| | 3402 | | { |
| 0 | 3403 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 3404 | | } |
| 3 | 3405 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 3 | 3406 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 3407 | | string _responseContent = null; |
| 3 | 3408 | | if ((int)_statusCode != 200) |
| | 3409 | | { |
| 0 | 3410 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 3411 | | try |
| | 3412 | | { |
| 0 | 3413 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 3414 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 3415 | | if (_errorBody != null) |
| | 3416 | | { |
| 0 | 3417 | | ex.Body = _errorBody; |
| | 3418 | | } |
| 0 | 3419 | | } |
| 0 | 3420 | | catch (JsonException) |
| | 3421 | | { |
| | 3422 | | // Ignore the exception |
| 0 | 3423 | | } |
| 0 | 3424 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 3425 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 3426 | | if (_shouldTrace) |
| | 3427 | | { |
| 0 | 3428 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 3429 | | } |
| 0 | 3430 | | _httpRequest.Dispose(); |
| 0 | 3431 | | if (_httpResponse != null) |
| | 3432 | | { |
| 0 | 3433 | | _httpResponse.Dispose(); |
| | 3434 | | } |
| 0 | 3435 | | throw ex; |
| | 3436 | | } |
| | 3437 | | // Create Result |
| 3 | 3438 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 3 | 3439 | | _result.Request = _httpRequest; |
| 3 | 3440 | | _result.Response = _httpResponse; |
| | 3441 | | // Deserialize Response |
| 3 | 3442 | | if ((int)_statusCode == 200) |
| | 3443 | | { |
| 3 | 3444 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 3445 | | try |
| | 3446 | | { |
| 3 | 3447 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 3 | 3448 | | } |
| 0 | 3449 | | catch (JsonException ex) |
| | 3450 | | { |
| 0 | 3451 | | _httpRequest.Dispose(); |
| 0 | 3452 | | if (_httpResponse != null) |
| | 3453 | | { |
| 0 | 3454 | | _httpResponse.Dispose(); |
| | 3455 | | } |
| 0 | 3456 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 3457 | | } |
| | 3458 | | } |
| 3 | 3459 | | if (_shouldTrace) |
| | 3460 | | { |
| 0 | 3461 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 3462 | | } |
| 3 | 3463 | | return _result; |
| 3 | 3464 | | } |
| | 3465 | |
|
| | 3466 | | /// <summary> |
| | 3467 | | /// Gets the information of the features used by the intent in a version of the |
| | 3468 | | /// application. |
| | 3469 | | /// </summary> |
| | 3470 | | /// <param name='appId'> |
| | 3471 | | /// The application ID. |
| | 3472 | | /// </param> |
| | 3473 | | /// <param name='versionId'> |
| | 3474 | | /// The version ID. |
| | 3475 | | /// </param> |
| | 3476 | | /// <param name='intentId'> |
| | 3477 | | /// The intent classifier ID. |
| | 3478 | | /// </param> |
| | 3479 | | /// <param name='customHeaders'> |
| | 3480 | | /// Headers that will be added to request. |
| | 3481 | | /// </param> |
| | 3482 | | /// <param name='cancellationToken'> |
| | 3483 | | /// The cancellation token. |
| | 3484 | | /// </param> |
| | 3485 | | /// <exception cref="ErrorResponseException"> |
| | 3486 | | /// Thrown when the operation returned an invalid status code |
| | 3487 | | /// </exception> |
| | 3488 | | /// <exception cref="SerializationException"> |
| | 3489 | | /// Thrown when unable to deserialize the response |
| | 3490 | | /// </exception> |
| | 3491 | | /// <exception cref="ValidationException"> |
| | 3492 | | /// Thrown when a required parameter is null |
| | 3493 | | /// </exception> |
| | 3494 | | /// <exception cref="System.ArgumentNullException"> |
| | 3495 | | /// Thrown when a required parameter is null |
| | 3496 | | /// </exception> |
| | 3497 | | /// <return> |
| | 3498 | | /// A response object containing the response body and response headers. |
| | 3499 | | /// </return> |
| | 3500 | | public async Task<HttpOperationResponse<IList<ModelFeatureInformation>>> GetIntentFeaturesWithHttpMessagesAsync( |
| | 3501 | | { |
| 1 | 3502 | | if (Client.Endpoint == null) |
| | 3503 | | { |
| 0 | 3504 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 3505 | | } |
| 1 | 3506 | | if (versionId == null) |
| | 3507 | | { |
| 0 | 3508 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 3509 | | } |
| | 3510 | | // Tracing |
| 1 | 3511 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 3512 | | string _invocationId = null; |
| 1 | 3513 | | if (_shouldTrace) |
| | 3514 | | { |
| 0 | 3515 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 3516 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 3517 | | tracingParameters.Add("appId", appId); |
| 0 | 3518 | | tracingParameters.Add("versionId", versionId); |
| 0 | 3519 | | tracingParameters.Add("intentId", intentId); |
| 0 | 3520 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 3521 | | ServiceClientTracing.Enter(_invocationId, this, "GetIntentFeatures", tracingParameters); |
| | 3522 | | } |
| | 3523 | | // Construct URL |
| 1 | 3524 | | var _baseUrl = Client.BaseUri; |
| 1 | 3525 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte |
| 1 | 3526 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 3527 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 3528 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 3529 | | _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 3530 | | // Create HTTP transport objects |
| 1 | 3531 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 3532 | | HttpResponseMessage _httpResponse = null; |
| 1 | 3533 | | _httpRequest.Method = new HttpMethod("GET"); |
| 1 | 3534 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 3535 | | // Set Headers |
| | 3536 | |
|
| | 3537 | |
|
| 1 | 3538 | | if (customHeaders != null) |
| | 3539 | | { |
| 0 | 3540 | | foreach(var _header in customHeaders) |
| | 3541 | | { |
| 0 | 3542 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 3543 | | { |
| 0 | 3544 | | _httpRequest.Headers.Remove(_header.Key); |
| | 3545 | | } |
| 0 | 3546 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 3547 | | } |
| | 3548 | | } |
| | 3549 | |
|
| | 3550 | | // Serialize Request |
| 1 | 3551 | | string _requestContent = null; |
| | 3552 | | // Set Credentials |
| 1 | 3553 | | if (Client.Credentials != null) |
| | 3554 | | { |
| 1 | 3555 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 3556 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 3557 | | } |
| | 3558 | | // Send Request |
| 1 | 3559 | | if (_shouldTrace) |
| | 3560 | | { |
| 0 | 3561 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 3562 | | } |
| 1 | 3563 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 3564 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 3565 | | if (_shouldTrace) |
| | 3566 | | { |
| 0 | 3567 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 3568 | | } |
| 1 | 3569 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 3570 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 3571 | | string _responseContent = null; |
| 1 | 3572 | | if ((int)_statusCode != 200) |
| | 3573 | | { |
| 0 | 3574 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 3575 | | try |
| | 3576 | | { |
| 0 | 3577 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 3578 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 3579 | | if (_errorBody != null) |
| | 3580 | | { |
| 0 | 3581 | | ex.Body = _errorBody; |
| | 3582 | | } |
| 0 | 3583 | | } |
| 0 | 3584 | | catch (JsonException) |
| | 3585 | | { |
| | 3586 | | // Ignore the exception |
| 0 | 3587 | | } |
| 0 | 3588 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 3589 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 3590 | | if (_shouldTrace) |
| | 3591 | | { |
| 0 | 3592 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 3593 | | } |
| 0 | 3594 | | _httpRequest.Dispose(); |
| 0 | 3595 | | if (_httpResponse != null) |
| | 3596 | | { |
| 0 | 3597 | | _httpResponse.Dispose(); |
| | 3598 | | } |
| 0 | 3599 | | throw ex; |
| | 3600 | | } |
| | 3601 | | // Create Result |
| 1 | 3602 | | var _result = new HttpOperationResponse<IList<ModelFeatureInformation>>(); |
| 1 | 3603 | | _result.Request = _httpRequest; |
| 1 | 3604 | | _result.Response = _httpResponse; |
| | 3605 | | // Deserialize Response |
| 1 | 3606 | | if ((int)_statusCode == 200) |
| | 3607 | | { |
| 1 | 3608 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 3609 | | try |
| | 3610 | | { |
| 1 | 3611 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<ModelFeatureInformation>>( |
| 1 | 3612 | | } |
| 0 | 3613 | | catch (JsonException ex) |
| | 3614 | | { |
| 0 | 3615 | | _httpRequest.Dispose(); |
| 0 | 3616 | | if (_httpResponse != null) |
| | 3617 | | { |
| 0 | 3618 | | _httpResponse.Dispose(); |
| | 3619 | | } |
| 0 | 3620 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 3621 | | } |
| | 3622 | | } |
| 1 | 3623 | | if (_shouldTrace) |
| | 3624 | | { |
| 0 | 3625 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 3626 | | } |
| 1 | 3627 | | return _result; |
| 1 | 3628 | | } |
| | 3629 | |
|
| | 3630 | | /// <summary> |
| | 3631 | | /// Updates the information of the features used by the intent in a version of |
| | 3632 | | /// the application. |
| | 3633 | | /// </summary> |
| | 3634 | | /// <param name='appId'> |
| | 3635 | | /// The application ID. |
| | 3636 | | /// </param> |
| | 3637 | | /// <param name='versionId'> |
| | 3638 | | /// The version ID. |
| | 3639 | | /// </param> |
| | 3640 | | /// <param name='intentId'> |
| | 3641 | | /// The intent classifier ID. |
| | 3642 | | /// </param> |
| | 3643 | | /// <param name='featureRelationsUpdateObject'> |
| | 3644 | | /// A list of feature information objects containing the new feature relations. |
| | 3645 | | /// </param> |
| | 3646 | | /// <param name='customHeaders'> |
| | 3647 | | /// Headers that will be added to request. |
| | 3648 | | /// </param> |
| | 3649 | | /// <param name='cancellationToken'> |
| | 3650 | | /// The cancellation token. |
| | 3651 | | /// </param> |
| | 3652 | | /// <exception cref="ErrorResponseException"> |
| | 3653 | | /// Thrown when the operation returned an invalid status code |
| | 3654 | | /// </exception> |
| | 3655 | | /// <exception cref="SerializationException"> |
| | 3656 | | /// Thrown when unable to deserialize the response |
| | 3657 | | /// </exception> |
| | 3658 | | /// <exception cref="ValidationException"> |
| | 3659 | | /// Thrown when a required parameter is null |
| | 3660 | | /// </exception> |
| | 3661 | | /// <exception cref="System.ArgumentNullException"> |
| | 3662 | | /// Thrown when a required parameter is null |
| | 3663 | | /// </exception> |
| | 3664 | | /// <return> |
| | 3665 | | /// A response object containing the response body and response headers. |
| | 3666 | | /// </return> |
| | 3667 | | public async Task<HttpOperationResponse<OperationStatus>> ReplaceIntentFeaturesWithHttpMessagesAsync(System.Guid |
| | 3668 | | { |
| 0 | 3669 | | if (Client.Endpoint == null) |
| | 3670 | | { |
| 0 | 3671 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 3672 | | } |
| 0 | 3673 | | if (versionId == null) |
| | 3674 | | { |
| 0 | 3675 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 3676 | | } |
| 0 | 3677 | | if (featureRelationsUpdateObject == null) |
| | 3678 | | { |
| 0 | 3679 | | throw new ValidationException(ValidationRules.CannotBeNull, "featureRelationsUpdateObject"); |
| | 3680 | | } |
| | 3681 | | // Tracing |
| 0 | 3682 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 3683 | | string _invocationId = null; |
| 0 | 3684 | | if (_shouldTrace) |
| | 3685 | | { |
| 0 | 3686 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 3687 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 3688 | | tracingParameters.Add("appId", appId); |
| 0 | 3689 | | tracingParameters.Add("versionId", versionId); |
| 0 | 3690 | | tracingParameters.Add("intentId", intentId); |
| 0 | 3691 | | tracingParameters.Add("featureRelationsUpdateObject", featureRelationsUpdateObject); |
| 0 | 3692 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 3693 | | ServiceClientTracing.Enter(_invocationId, this, "ReplaceIntentFeatures", tracingParameters); |
| | 3694 | | } |
| | 3695 | | // Construct URL |
| 0 | 3696 | | var _baseUrl = Client.BaseUri; |
| 0 | 3697 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte |
| 0 | 3698 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 3699 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 3700 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 3701 | | _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 3702 | | // Create HTTP transport objects |
| 0 | 3703 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 3704 | | HttpResponseMessage _httpResponse = null; |
| 0 | 3705 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 0 | 3706 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 3707 | | // Set Headers |
| | 3708 | |
|
| | 3709 | |
|
| 0 | 3710 | | if (customHeaders != null) |
| | 3711 | | { |
| 0 | 3712 | | foreach(var _header in customHeaders) |
| | 3713 | | { |
| 0 | 3714 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 3715 | | { |
| 0 | 3716 | | _httpRequest.Headers.Remove(_header.Key); |
| | 3717 | | } |
| 0 | 3718 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 3719 | | } |
| | 3720 | | } |
| | 3721 | |
|
| | 3722 | | // Serialize Request |
| 0 | 3723 | | string _requestContent = null; |
| 0 | 3724 | | if(featureRelationsUpdateObject != null) |
| | 3725 | | { |
| 0 | 3726 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(featureRelationsUpdateObject, Clien |
| 0 | 3727 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 3728 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 3729 | | } |
| | 3730 | | // Set Credentials |
| 0 | 3731 | | if (Client.Credentials != null) |
| | 3732 | | { |
| 0 | 3733 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 3734 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 3735 | | } |
| | 3736 | | // Send Request |
| 0 | 3737 | | if (_shouldTrace) |
| | 3738 | | { |
| 0 | 3739 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 3740 | | } |
| 0 | 3741 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 3742 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 3743 | | if (_shouldTrace) |
| | 3744 | | { |
| 0 | 3745 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 3746 | | } |
| 0 | 3747 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 3748 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 3749 | | string _responseContent = null; |
| 0 | 3750 | | if ((int)_statusCode != 200) |
| | 3751 | | { |
| 0 | 3752 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 3753 | | try |
| | 3754 | | { |
| 0 | 3755 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 3756 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 3757 | | if (_errorBody != null) |
| | 3758 | | { |
| 0 | 3759 | | ex.Body = _errorBody; |
| | 3760 | | } |
| 0 | 3761 | | } |
| 0 | 3762 | | catch (JsonException) |
| | 3763 | | { |
| | 3764 | | // Ignore the exception |
| 0 | 3765 | | } |
| 0 | 3766 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 3767 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 3768 | | if (_shouldTrace) |
| | 3769 | | { |
| 0 | 3770 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 3771 | | } |
| 0 | 3772 | | _httpRequest.Dispose(); |
| 0 | 3773 | | if (_httpResponse != null) |
| | 3774 | | { |
| 0 | 3775 | | _httpResponse.Dispose(); |
| | 3776 | | } |
| 0 | 3777 | | throw ex; |
| | 3778 | | } |
| | 3779 | | // Create Result |
| 0 | 3780 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 0 | 3781 | | _result.Request = _httpRequest; |
| 0 | 3782 | | _result.Response = _httpResponse; |
| | 3783 | | // Deserialize Response |
| 0 | 3784 | | if ((int)_statusCode == 200) |
| | 3785 | | { |
| 0 | 3786 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 3787 | | try |
| | 3788 | | { |
| 0 | 3789 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 0 | 3790 | | } |
| 0 | 3791 | | catch (JsonException ex) |
| | 3792 | | { |
| 0 | 3793 | | _httpRequest.Dispose(); |
| 0 | 3794 | | if (_httpResponse != null) |
| | 3795 | | { |
| 0 | 3796 | | _httpResponse.Dispose(); |
| | 3797 | | } |
| 0 | 3798 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 3799 | | } |
| | 3800 | | } |
| 0 | 3801 | | if (_shouldTrace) |
| | 3802 | | { |
| 0 | 3803 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 3804 | | } |
| 0 | 3805 | | return _result; |
| 0 | 3806 | | } |
| | 3807 | |
|
| | 3808 | | /// <summary> |
| | 3809 | | /// Deletes a relation from the feature relations used by the intent in a |
| | 3810 | | /// version of the application. |
| | 3811 | | /// </summary> |
| | 3812 | | /// <param name='appId'> |
| | 3813 | | /// The application ID. |
| | 3814 | | /// </param> |
| | 3815 | | /// <param name='versionId'> |
| | 3816 | | /// The version ID. |
| | 3817 | | /// </param> |
| | 3818 | | /// <param name='intentId'> |
| | 3819 | | /// The intent classifier ID. |
| | 3820 | | /// </param> |
| | 3821 | | /// <param name='featureRelationDeleteObject'> |
| | 3822 | | /// A feature information object containing the feature relation to delete. |
| | 3823 | | /// </param> |
| | 3824 | | /// <param name='customHeaders'> |
| | 3825 | | /// Headers that will be added to request. |
| | 3826 | | /// </param> |
| | 3827 | | /// <param name='cancellationToken'> |
| | 3828 | | /// The cancellation token. |
| | 3829 | | /// </param> |
| | 3830 | | /// <exception cref="ErrorResponseException"> |
| | 3831 | | /// Thrown when the operation returned an invalid status code |
| | 3832 | | /// </exception> |
| | 3833 | | /// <exception cref="SerializationException"> |
| | 3834 | | /// Thrown when unable to deserialize the response |
| | 3835 | | /// </exception> |
| | 3836 | | /// <exception cref="ValidationException"> |
| | 3837 | | /// Thrown when a required parameter is null |
| | 3838 | | /// </exception> |
| | 3839 | | /// <exception cref="System.ArgumentNullException"> |
| | 3840 | | /// Thrown when a required parameter is null |
| | 3841 | | /// </exception> |
| | 3842 | | /// <return> |
| | 3843 | | /// A response object containing the response body and response headers. |
| | 3844 | | /// </return> |
| | 3845 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteIntentFeatureWithHttpMessagesAsync(System.Guid a |
| | 3846 | | { |
| 1 | 3847 | | if (Client.Endpoint == null) |
| | 3848 | | { |
| 0 | 3849 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 3850 | | } |
| 1 | 3851 | | if (versionId == null) |
| | 3852 | | { |
| 0 | 3853 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 3854 | | } |
| 1 | 3855 | | if (featureRelationDeleteObject == null) |
| | 3856 | | { |
| 0 | 3857 | | throw new ValidationException(ValidationRules.CannotBeNull, "featureRelationDeleteObject"); |
| | 3858 | | } |
| | 3859 | | // Tracing |
| 1 | 3860 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 3861 | | string _invocationId = null; |
| 1 | 3862 | | if (_shouldTrace) |
| | 3863 | | { |
| 0 | 3864 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 3865 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 3866 | | tracingParameters.Add("appId", appId); |
| 0 | 3867 | | tracingParameters.Add("versionId", versionId); |
| 0 | 3868 | | tracingParameters.Add("intentId", intentId); |
| 0 | 3869 | | tracingParameters.Add("featureRelationDeleteObject", featureRelationDeleteObject); |
| 0 | 3870 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 3871 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteIntentFeature", tracingParameters); |
| | 3872 | | } |
| | 3873 | | // Construct URL |
| 1 | 3874 | | var _baseUrl = Client.BaseUri; |
| 1 | 3875 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte |
| 1 | 3876 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 3877 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 3878 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 3879 | | _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 3880 | | // Create HTTP transport objects |
| 1 | 3881 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 3882 | | HttpResponseMessage _httpResponse = null; |
| 1 | 3883 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 1 | 3884 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 3885 | | // Set Headers |
| | 3886 | |
|
| | 3887 | |
|
| 1 | 3888 | | if (customHeaders != null) |
| | 3889 | | { |
| 0 | 3890 | | foreach(var _header in customHeaders) |
| | 3891 | | { |
| 0 | 3892 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 3893 | | { |
| 0 | 3894 | | _httpRequest.Headers.Remove(_header.Key); |
| | 3895 | | } |
| 0 | 3896 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 3897 | | } |
| | 3898 | | } |
| | 3899 | |
|
| | 3900 | | // Serialize Request |
| 1 | 3901 | | string _requestContent = null; |
| 1 | 3902 | | if(featureRelationDeleteObject != null) |
| | 3903 | | { |
| 1 | 3904 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(featureRelationDeleteObject, Client |
| 1 | 3905 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 3906 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 3907 | | } |
| | 3908 | | // Set Credentials |
| 1 | 3909 | | if (Client.Credentials != null) |
| | 3910 | | { |
| 1 | 3911 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 3912 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 3913 | | } |
| | 3914 | | // Send Request |
| 1 | 3915 | | if (_shouldTrace) |
| | 3916 | | { |
| 0 | 3917 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 3918 | | } |
| 1 | 3919 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 3920 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 3921 | | if (_shouldTrace) |
| | 3922 | | { |
| 0 | 3923 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 3924 | | } |
| 1 | 3925 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 3926 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 3927 | | string _responseContent = null; |
| 1 | 3928 | | if ((int)_statusCode != 200) |
| | 3929 | | { |
| 0 | 3930 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 3931 | | try |
| | 3932 | | { |
| 0 | 3933 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 3934 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 3935 | | if (_errorBody != null) |
| | 3936 | | { |
| 0 | 3937 | | ex.Body = _errorBody; |
| | 3938 | | } |
| 0 | 3939 | | } |
| 0 | 3940 | | catch (JsonException) |
| | 3941 | | { |
| | 3942 | | // Ignore the exception |
| 0 | 3943 | | } |
| 0 | 3944 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 3945 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 3946 | | if (_shouldTrace) |
| | 3947 | | { |
| 0 | 3948 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 3949 | | } |
| 0 | 3950 | | _httpRequest.Dispose(); |
| 0 | 3951 | | if (_httpResponse != null) |
| | 3952 | | { |
| 0 | 3953 | | _httpResponse.Dispose(); |
| | 3954 | | } |
| 0 | 3955 | | throw ex; |
| | 3956 | | } |
| | 3957 | | // Create Result |
| 1 | 3958 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 3959 | | _result.Request = _httpRequest; |
| 1 | 3960 | | _result.Response = _httpResponse; |
| | 3961 | | // Deserialize Response |
| 1 | 3962 | | if ((int)_statusCode == 200) |
| | 3963 | | { |
| 1 | 3964 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 3965 | | try |
| | 3966 | | { |
| 1 | 3967 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 3968 | | } |
| 0 | 3969 | | catch (JsonException ex) |
| | 3970 | | { |
| 0 | 3971 | | _httpRequest.Dispose(); |
| 0 | 3972 | | if (_httpResponse != null) |
| | 3973 | | { |
| 0 | 3974 | | _httpResponse.Dispose(); |
| | 3975 | | } |
| 0 | 3976 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 3977 | | } |
| | 3978 | | } |
| 1 | 3979 | | if (_shouldTrace) |
| | 3980 | | { |
| 0 | 3981 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 3982 | | } |
| 1 | 3983 | | return _result; |
| 1 | 3984 | | } |
| | 3985 | |
|
| | 3986 | | /// <summary> |
| | 3987 | | /// Gets the information of the features used by the entity in a version of the |
| | 3988 | | /// application. |
| | 3989 | | /// </summary> |
| | 3990 | | /// <param name='appId'> |
| | 3991 | | /// The application ID. |
| | 3992 | | /// </param> |
| | 3993 | | /// <param name='versionId'> |
| | 3994 | | /// The version ID. |
| | 3995 | | /// </param> |
| | 3996 | | /// <param name='entityId'> |
| | 3997 | | /// The entity extractor ID. |
| | 3998 | | /// </param> |
| | 3999 | | /// <param name='customHeaders'> |
| | 4000 | | /// Headers that will be added to request. |
| | 4001 | | /// </param> |
| | 4002 | | /// <param name='cancellationToken'> |
| | 4003 | | /// The cancellation token. |
| | 4004 | | /// </param> |
| | 4005 | | /// <exception cref="ErrorResponseException"> |
| | 4006 | | /// Thrown when the operation returned an invalid status code |
| | 4007 | | /// </exception> |
| | 4008 | | /// <exception cref="SerializationException"> |
| | 4009 | | /// Thrown when unable to deserialize the response |
| | 4010 | | /// </exception> |
| | 4011 | | /// <exception cref="ValidationException"> |
| | 4012 | | /// Thrown when a required parameter is null |
| | 4013 | | /// </exception> |
| | 4014 | | /// <exception cref="System.ArgumentNullException"> |
| | 4015 | | /// Thrown when a required parameter is null |
| | 4016 | | /// </exception> |
| | 4017 | | /// <return> |
| | 4018 | | /// A response object containing the response body and response headers. |
| | 4019 | | /// </return> |
| | 4020 | | public async Task<HttpOperationResponse<IList<ModelFeatureInformation>>> GetEntityFeaturesWithHttpMessagesAsync( |
| | 4021 | | { |
| 2 | 4022 | | if (Client.Endpoint == null) |
| | 4023 | | { |
| 0 | 4024 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 4025 | | } |
| 2 | 4026 | | if (versionId == null) |
| | 4027 | | { |
| 0 | 4028 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 4029 | | } |
| | 4030 | | // Tracing |
| 2 | 4031 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 4032 | | string _invocationId = null; |
| 2 | 4033 | | if (_shouldTrace) |
| | 4034 | | { |
| 0 | 4035 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 4036 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 4037 | | tracingParameters.Add("appId", appId); |
| 0 | 4038 | | tracingParameters.Add("versionId", versionId); |
| 0 | 4039 | | tracingParameters.Add("entityId", entityId); |
| 0 | 4040 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 4041 | | ServiceClientTracing.Enter(_invocationId, this, "GetEntityFeatures", tracingParameters); |
| | 4042 | | } |
| | 4043 | | // Construct URL |
| 2 | 4044 | | var _baseUrl = Client.BaseUri; |
| 2 | 4045 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent |
| 2 | 4046 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 4047 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 4048 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 2 | 4049 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 4050 | | // Create HTTP transport objects |
| 2 | 4051 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 4052 | | HttpResponseMessage _httpResponse = null; |
| 2 | 4053 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 4054 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 4055 | | // Set Headers |
| | 4056 | |
|
| | 4057 | |
|
| 2 | 4058 | | if (customHeaders != null) |
| | 4059 | | { |
| 0 | 4060 | | foreach(var _header in customHeaders) |
| | 4061 | | { |
| 0 | 4062 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 4063 | | { |
| 0 | 4064 | | _httpRequest.Headers.Remove(_header.Key); |
| | 4065 | | } |
| 0 | 4066 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 4067 | | } |
| | 4068 | | } |
| | 4069 | |
|
| | 4070 | | // Serialize Request |
| 2 | 4071 | | string _requestContent = null; |
| | 4072 | | // Set Credentials |
| 2 | 4073 | | if (Client.Credentials != null) |
| | 4074 | | { |
| 2 | 4075 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 4076 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 4077 | | } |
| | 4078 | | // Send Request |
| 2 | 4079 | | if (_shouldTrace) |
| | 4080 | | { |
| 0 | 4081 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 4082 | | } |
| 2 | 4083 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 4084 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 4085 | | if (_shouldTrace) |
| | 4086 | | { |
| 0 | 4087 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 4088 | | } |
| 2 | 4089 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 4090 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 4091 | | string _responseContent = null; |
| 2 | 4092 | | if ((int)_statusCode != 200) |
| | 4093 | | { |
| 0 | 4094 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 4095 | | try |
| | 4096 | | { |
| 0 | 4097 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 4098 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 4099 | | if (_errorBody != null) |
| | 4100 | | { |
| 0 | 4101 | | ex.Body = _errorBody; |
| | 4102 | | } |
| 0 | 4103 | | } |
| 0 | 4104 | | catch (JsonException) |
| | 4105 | | { |
| | 4106 | | // Ignore the exception |
| 0 | 4107 | | } |
| 0 | 4108 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 4109 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 4110 | | if (_shouldTrace) |
| | 4111 | | { |
| 0 | 4112 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 4113 | | } |
| 0 | 4114 | | _httpRequest.Dispose(); |
| 0 | 4115 | | if (_httpResponse != null) |
| | 4116 | | { |
| 0 | 4117 | | _httpResponse.Dispose(); |
| | 4118 | | } |
| 0 | 4119 | | throw ex; |
| | 4120 | | } |
| | 4121 | | // Create Result |
| 2 | 4122 | | var _result = new HttpOperationResponse<IList<ModelFeatureInformation>>(); |
| 2 | 4123 | | _result.Request = _httpRequest; |
| 2 | 4124 | | _result.Response = _httpResponse; |
| | 4125 | | // Deserialize Response |
| 2 | 4126 | | if ((int)_statusCode == 200) |
| | 4127 | | { |
| 2 | 4128 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 4129 | | try |
| | 4130 | | { |
| 2 | 4131 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<ModelFeatureInformation>>( |
| 2 | 4132 | | } |
| 0 | 4133 | | catch (JsonException ex) |
| | 4134 | | { |
| 0 | 4135 | | _httpRequest.Dispose(); |
| 0 | 4136 | | if (_httpResponse != null) |
| | 4137 | | { |
| 0 | 4138 | | _httpResponse.Dispose(); |
| | 4139 | | } |
| 0 | 4140 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 4141 | | } |
| | 4142 | | } |
| 2 | 4143 | | if (_shouldTrace) |
| | 4144 | | { |
| 0 | 4145 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 4146 | | } |
| 2 | 4147 | | return _result; |
| 2 | 4148 | | } |
| | 4149 | |
|
| | 4150 | | /// <summary> |
| | 4151 | | /// Updates the information of the features used by the entity in a version of |
| | 4152 | | /// the application. |
| | 4153 | | /// </summary> |
| | 4154 | | /// <param name='appId'> |
| | 4155 | | /// The application ID. |
| | 4156 | | /// </param> |
| | 4157 | | /// <param name='versionId'> |
| | 4158 | | /// The version ID. |
| | 4159 | | /// </param> |
| | 4160 | | /// <param name='entityId'> |
| | 4161 | | /// The entity extractor ID. |
| | 4162 | | /// </param> |
| | 4163 | | /// <param name='featureRelationsUpdateObject'> |
| | 4164 | | /// A list of feature information objects containing the new feature relations. |
| | 4165 | | /// </param> |
| | 4166 | | /// <param name='customHeaders'> |
| | 4167 | | /// Headers that will be added to request. |
| | 4168 | | /// </param> |
| | 4169 | | /// <param name='cancellationToken'> |
| | 4170 | | /// The cancellation token. |
| | 4171 | | /// </param> |
| | 4172 | | /// <exception cref="ErrorResponseException"> |
| | 4173 | | /// Thrown when the operation returned an invalid status code |
| | 4174 | | /// </exception> |
| | 4175 | | /// <exception cref="SerializationException"> |
| | 4176 | | /// Thrown when unable to deserialize the response |
| | 4177 | | /// </exception> |
| | 4178 | | /// <exception cref="ValidationException"> |
| | 4179 | | /// Thrown when a required parameter is null |
| | 4180 | | /// </exception> |
| | 4181 | | /// <exception cref="System.ArgumentNullException"> |
| | 4182 | | /// Thrown when a required parameter is null |
| | 4183 | | /// </exception> |
| | 4184 | | /// <return> |
| | 4185 | | /// A response object containing the response body and response headers. |
| | 4186 | | /// </return> |
| | 4187 | | public async Task<HttpOperationResponse<OperationStatus>> ReplaceEntityFeaturesWithHttpMessagesAsync(System.Guid |
| | 4188 | | { |
| 0 | 4189 | | if (Client.Endpoint == null) |
| | 4190 | | { |
| 0 | 4191 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 4192 | | } |
| 0 | 4193 | | if (versionId == null) |
| | 4194 | | { |
| 0 | 4195 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 4196 | | } |
| 0 | 4197 | | if (featureRelationsUpdateObject == null) |
| | 4198 | | { |
| 0 | 4199 | | throw new ValidationException(ValidationRules.CannotBeNull, "featureRelationsUpdateObject"); |
| | 4200 | | } |
| | 4201 | | // Tracing |
| 0 | 4202 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 4203 | | string _invocationId = null; |
| 0 | 4204 | | if (_shouldTrace) |
| | 4205 | | { |
| 0 | 4206 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 4207 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 4208 | | tracingParameters.Add("appId", appId); |
| 0 | 4209 | | tracingParameters.Add("versionId", versionId); |
| 0 | 4210 | | tracingParameters.Add("entityId", entityId); |
| 0 | 4211 | | tracingParameters.Add("featureRelationsUpdateObject", featureRelationsUpdateObject); |
| 0 | 4212 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 4213 | | ServiceClientTracing.Enter(_invocationId, this, "ReplaceEntityFeatures", tracingParameters); |
| | 4214 | | } |
| | 4215 | | // Construct URL |
| 0 | 4216 | | var _baseUrl = Client.BaseUri; |
| 0 | 4217 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent |
| 0 | 4218 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 4219 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 4220 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 4221 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 4222 | | // Create HTTP transport objects |
| 0 | 4223 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 4224 | | HttpResponseMessage _httpResponse = null; |
| 0 | 4225 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 0 | 4226 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 4227 | | // Set Headers |
| | 4228 | |
|
| | 4229 | |
|
| 0 | 4230 | | if (customHeaders != null) |
| | 4231 | | { |
| 0 | 4232 | | foreach(var _header in customHeaders) |
| | 4233 | | { |
| 0 | 4234 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 4235 | | { |
| 0 | 4236 | | _httpRequest.Headers.Remove(_header.Key); |
| | 4237 | | } |
| 0 | 4238 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 4239 | | } |
| | 4240 | | } |
| | 4241 | |
|
| | 4242 | | // Serialize Request |
| 0 | 4243 | | string _requestContent = null; |
| 0 | 4244 | | if(featureRelationsUpdateObject != null) |
| | 4245 | | { |
| 0 | 4246 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(featureRelationsUpdateObject, Clien |
| 0 | 4247 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 4248 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 4249 | | } |
| | 4250 | | // Set Credentials |
| 0 | 4251 | | if (Client.Credentials != null) |
| | 4252 | | { |
| 0 | 4253 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 4254 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 4255 | | } |
| | 4256 | | // Send Request |
| 0 | 4257 | | if (_shouldTrace) |
| | 4258 | | { |
| 0 | 4259 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 4260 | | } |
| 0 | 4261 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 4262 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 4263 | | if (_shouldTrace) |
| | 4264 | | { |
| 0 | 4265 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 4266 | | } |
| 0 | 4267 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 4268 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 4269 | | string _responseContent = null; |
| 0 | 4270 | | if ((int)_statusCode != 200) |
| | 4271 | | { |
| 0 | 4272 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 4273 | | try |
| | 4274 | | { |
| 0 | 4275 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 4276 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 4277 | | if (_errorBody != null) |
| | 4278 | | { |
| 0 | 4279 | | ex.Body = _errorBody; |
| | 4280 | | } |
| 0 | 4281 | | } |
| 0 | 4282 | | catch (JsonException) |
| | 4283 | | { |
| | 4284 | | // Ignore the exception |
| 0 | 4285 | | } |
| 0 | 4286 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 4287 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 4288 | | if (_shouldTrace) |
| | 4289 | | { |
| 0 | 4290 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 4291 | | } |
| 0 | 4292 | | _httpRequest.Dispose(); |
| 0 | 4293 | | if (_httpResponse != null) |
| | 4294 | | { |
| 0 | 4295 | | _httpResponse.Dispose(); |
| | 4296 | | } |
| 0 | 4297 | | throw ex; |
| | 4298 | | } |
| | 4299 | | // Create Result |
| 0 | 4300 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 0 | 4301 | | _result.Request = _httpRequest; |
| 0 | 4302 | | _result.Response = _httpResponse; |
| | 4303 | | // Deserialize Response |
| 0 | 4304 | | if ((int)_statusCode == 200) |
| | 4305 | | { |
| 0 | 4306 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 4307 | | try |
| | 4308 | | { |
| 0 | 4309 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 0 | 4310 | | } |
| 0 | 4311 | | catch (JsonException ex) |
| | 4312 | | { |
| 0 | 4313 | | _httpRequest.Dispose(); |
| 0 | 4314 | | if (_httpResponse != null) |
| | 4315 | | { |
| 0 | 4316 | | _httpResponse.Dispose(); |
| | 4317 | | } |
| 0 | 4318 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 4319 | | } |
| | 4320 | | } |
| 0 | 4321 | | if (_shouldTrace) |
| | 4322 | | { |
| 0 | 4323 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 4324 | | } |
| 0 | 4325 | | return _result; |
| 0 | 4326 | | } |
| | 4327 | |
|
| | 4328 | | /// <summary> |
| | 4329 | | /// Deletes a relation from the feature relations used by the entity in a |
| | 4330 | | /// version of the application. |
| | 4331 | | /// </summary> |
| | 4332 | | /// <param name='appId'> |
| | 4333 | | /// The application ID. |
| | 4334 | | /// </param> |
| | 4335 | | /// <param name='versionId'> |
| | 4336 | | /// The version ID. |
| | 4337 | | /// </param> |
| | 4338 | | /// <param name='entityId'> |
| | 4339 | | /// The entity extractor ID. |
| | 4340 | | /// </param> |
| | 4341 | | /// <param name='featureRelationDeleteObject'> |
| | 4342 | | /// A feature information object containing the feature relation to delete. |
| | 4343 | | /// </param> |
| | 4344 | | /// <param name='customHeaders'> |
| | 4345 | | /// Headers that will be added to request. |
| | 4346 | | /// </param> |
| | 4347 | | /// <param name='cancellationToken'> |
| | 4348 | | /// The cancellation token. |
| | 4349 | | /// </param> |
| | 4350 | | /// <exception cref="ErrorResponseException"> |
| | 4351 | | /// Thrown when the operation returned an invalid status code |
| | 4352 | | /// </exception> |
| | 4353 | | /// <exception cref="SerializationException"> |
| | 4354 | | /// Thrown when unable to deserialize the response |
| | 4355 | | /// </exception> |
| | 4356 | | /// <exception cref="ValidationException"> |
| | 4357 | | /// Thrown when a required parameter is null |
| | 4358 | | /// </exception> |
| | 4359 | | /// <exception cref="System.ArgumentNullException"> |
| | 4360 | | /// Thrown when a required parameter is null |
| | 4361 | | /// </exception> |
| | 4362 | | /// <return> |
| | 4363 | | /// A response object containing the response body and response headers. |
| | 4364 | | /// </return> |
| | 4365 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteEntityFeatureWithHttpMessagesAsync(System.Guid a |
| | 4366 | | { |
| 1 | 4367 | | if (Client.Endpoint == null) |
| | 4368 | | { |
| 0 | 4369 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 4370 | | } |
| 1 | 4371 | | if (versionId == null) |
| | 4372 | | { |
| 0 | 4373 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 4374 | | } |
| 1 | 4375 | | if (featureRelationDeleteObject == null) |
| | 4376 | | { |
| 0 | 4377 | | throw new ValidationException(ValidationRules.CannotBeNull, "featureRelationDeleteObject"); |
| | 4378 | | } |
| | 4379 | | // Tracing |
| 1 | 4380 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 4381 | | string _invocationId = null; |
| 1 | 4382 | | if (_shouldTrace) |
| | 4383 | | { |
| 0 | 4384 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 4385 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 4386 | | tracingParameters.Add("appId", appId); |
| 0 | 4387 | | tracingParameters.Add("versionId", versionId); |
| 0 | 4388 | | tracingParameters.Add("entityId", entityId); |
| 0 | 4389 | | tracingParameters.Add("featureRelationDeleteObject", featureRelationDeleteObject); |
| 0 | 4390 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 4391 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteEntityFeature", tracingParameters); |
| | 4392 | | } |
| | 4393 | | // Construct URL |
| 1 | 4394 | | var _baseUrl = Client.BaseUri; |
| 1 | 4395 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent |
| 1 | 4396 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 4397 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 4398 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 4399 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 4400 | | // Create HTTP transport objects |
| 1 | 4401 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 4402 | | HttpResponseMessage _httpResponse = null; |
| 1 | 4403 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 1 | 4404 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 4405 | | // Set Headers |
| | 4406 | |
|
| | 4407 | |
|
| 1 | 4408 | | if (customHeaders != null) |
| | 4409 | | { |
| 0 | 4410 | | foreach(var _header in customHeaders) |
| | 4411 | | { |
| 0 | 4412 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 4413 | | { |
| 0 | 4414 | | _httpRequest.Headers.Remove(_header.Key); |
| | 4415 | | } |
| 0 | 4416 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 4417 | | } |
| | 4418 | | } |
| | 4419 | |
|
| | 4420 | | // Serialize Request |
| 1 | 4421 | | string _requestContent = null; |
| 1 | 4422 | | if(featureRelationDeleteObject != null) |
| | 4423 | | { |
| 1 | 4424 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(featureRelationDeleteObject, Client |
| 1 | 4425 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 4426 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 4427 | | } |
| | 4428 | | // Set Credentials |
| 1 | 4429 | | if (Client.Credentials != null) |
| | 4430 | | { |
| 1 | 4431 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 4432 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 4433 | | } |
| | 4434 | | // Send Request |
| 1 | 4435 | | if (_shouldTrace) |
| | 4436 | | { |
| 0 | 4437 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 4438 | | } |
| 1 | 4439 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 4440 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 4441 | | if (_shouldTrace) |
| | 4442 | | { |
| 0 | 4443 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 4444 | | } |
| 1 | 4445 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 4446 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 4447 | | string _responseContent = null; |
| 1 | 4448 | | if ((int)_statusCode != 200) |
| | 4449 | | { |
| 0 | 4450 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 4451 | | try |
| | 4452 | | { |
| 0 | 4453 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 4454 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 4455 | | if (_errorBody != null) |
| | 4456 | | { |
| 0 | 4457 | | ex.Body = _errorBody; |
| | 4458 | | } |
| 0 | 4459 | | } |
| 0 | 4460 | | catch (JsonException) |
| | 4461 | | { |
| | 4462 | | // Ignore the exception |
| 0 | 4463 | | } |
| 0 | 4464 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 4465 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 4466 | | if (_shouldTrace) |
| | 4467 | | { |
| 0 | 4468 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 4469 | | } |
| 0 | 4470 | | _httpRequest.Dispose(); |
| 0 | 4471 | | if (_httpResponse != null) |
| | 4472 | | { |
| 0 | 4473 | | _httpResponse.Dispose(); |
| | 4474 | | } |
| 0 | 4475 | | throw ex; |
| | 4476 | | } |
| | 4477 | | // Create Result |
| 1 | 4478 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 4479 | | _result.Request = _httpRequest; |
| 1 | 4480 | | _result.Response = _httpResponse; |
| | 4481 | | // Deserialize Response |
| 1 | 4482 | | if ((int)_statusCode == 200) |
| | 4483 | | { |
| 1 | 4484 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 4485 | | try |
| | 4486 | | { |
| 1 | 4487 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 4488 | | } |
| 0 | 4489 | | catch (JsonException ex) |
| | 4490 | | { |
| 0 | 4491 | | _httpRequest.Dispose(); |
| 0 | 4492 | | if (_httpResponse != null) |
| | 4493 | | { |
| 0 | 4494 | | _httpResponse.Dispose(); |
| | 4495 | | } |
| 0 | 4496 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 4497 | | } |
| | 4498 | | } |
| 1 | 4499 | | if (_shouldTrace) |
| | 4500 | | { |
| 0 | 4501 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 4502 | | } |
| 1 | 4503 | | return _result; |
| 1 | 4504 | | } |
| | 4505 | |
|
| | 4506 | | /// <summary> |
| | 4507 | | /// Gets information about a hierarchical entity in a version of the |
| | 4508 | | /// application. |
| | 4509 | | /// </summary> |
| | 4510 | | /// <param name='appId'> |
| | 4511 | | /// The application ID. |
| | 4512 | | /// </param> |
| | 4513 | | /// <param name='versionId'> |
| | 4514 | | /// The version ID. |
| | 4515 | | /// </param> |
| | 4516 | | /// <param name='hEntityId'> |
| | 4517 | | /// The hierarchical entity extractor ID. |
| | 4518 | | /// </param> |
| | 4519 | | /// <param name='customHeaders'> |
| | 4520 | | /// Headers that will be added to request. |
| | 4521 | | /// </param> |
| | 4522 | | /// <param name='cancellationToken'> |
| | 4523 | | /// The cancellation token. |
| | 4524 | | /// </param> |
| | 4525 | | /// <exception cref="ErrorResponseException"> |
| | 4526 | | /// Thrown when the operation returned an invalid status code |
| | 4527 | | /// </exception> |
| | 4528 | | /// <exception cref="SerializationException"> |
| | 4529 | | /// Thrown when unable to deserialize the response |
| | 4530 | | /// </exception> |
| | 4531 | | /// <exception cref="ValidationException"> |
| | 4532 | | /// Thrown when a required parameter is null |
| | 4533 | | /// </exception> |
| | 4534 | | /// <exception cref="System.ArgumentNullException"> |
| | 4535 | | /// Thrown when a required parameter is null |
| | 4536 | | /// </exception> |
| | 4537 | | /// <return> |
| | 4538 | | /// A response object containing the response body and response headers. |
| | 4539 | | /// </return> |
| | 4540 | | public async Task<HttpOperationResponse<HierarchicalEntityExtractor>> GetHierarchicalEntityWithHttpMessagesAsync |
| | 4541 | | { |
| 0 | 4542 | | if (Client.Endpoint == null) |
| | 4543 | | { |
| 0 | 4544 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 4545 | | } |
| 0 | 4546 | | if (versionId == null) |
| | 4547 | | { |
| 0 | 4548 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 4549 | | } |
| | 4550 | | // Tracing |
| 0 | 4551 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 4552 | | string _invocationId = null; |
| 0 | 4553 | | if (_shouldTrace) |
| | 4554 | | { |
| 0 | 4555 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 4556 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 4557 | | tracingParameters.Add("appId", appId); |
| 0 | 4558 | | tracingParameters.Add("versionId", versionId); |
| 0 | 4559 | | tracingParameters.Add("hEntityId", hEntityId); |
| 0 | 4560 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 4561 | | ServiceClientTracing.Enter(_invocationId, this, "GetHierarchicalEntity", tracingParameters); |
| | 4562 | | } |
| | 4563 | | // Construct URL |
| 0 | 4564 | | var _baseUrl = Client.BaseUri; |
| 0 | 4565 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale |
| 0 | 4566 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 4567 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 4568 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 4569 | | _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| | 4570 | | // Create HTTP transport objects |
| 0 | 4571 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 4572 | | HttpResponseMessage _httpResponse = null; |
| 0 | 4573 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 4574 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 4575 | | // Set Headers |
| | 4576 | |
|
| | 4577 | |
|
| 0 | 4578 | | if (customHeaders != null) |
| | 4579 | | { |
| 0 | 4580 | | foreach(var _header in customHeaders) |
| | 4581 | | { |
| 0 | 4582 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 4583 | | { |
| 0 | 4584 | | _httpRequest.Headers.Remove(_header.Key); |
| | 4585 | | } |
| 0 | 4586 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 4587 | | } |
| | 4588 | | } |
| | 4589 | |
|
| | 4590 | | // Serialize Request |
| 0 | 4591 | | string _requestContent = null; |
| | 4592 | | // Set Credentials |
| 0 | 4593 | | if (Client.Credentials != null) |
| | 4594 | | { |
| 0 | 4595 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 4596 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 4597 | | } |
| | 4598 | | // Send Request |
| 0 | 4599 | | if (_shouldTrace) |
| | 4600 | | { |
| 0 | 4601 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 4602 | | } |
| 0 | 4603 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 4604 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 4605 | | if (_shouldTrace) |
| | 4606 | | { |
| 0 | 4607 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 4608 | | } |
| 0 | 4609 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 4610 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 4611 | | string _responseContent = null; |
| 0 | 4612 | | if ((int)_statusCode != 200) |
| | 4613 | | { |
| 0 | 4614 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 4615 | | try |
| | 4616 | | { |
| 0 | 4617 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 4618 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 4619 | | if (_errorBody != null) |
| | 4620 | | { |
| 0 | 4621 | | ex.Body = _errorBody; |
| | 4622 | | } |
| 0 | 4623 | | } |
| 0 | 4624 | | catch (JsonException) |
| | 4625 | | { |
| | 4626 | | // Ignore the exception |
| 0 | 4627 | | } |
| 0 | 4628 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 4629 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 4630 | | if (_shouldTrace) |
| | 4631 | | { |
| 0 | 4632 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 4633 | | } |
| 0 | 4634 | | _httpRequest.Dispose(); |
| 0 | 4635 | | if (_httpResponse != null) |
| | 4636 | | { |
| 0 | 4637 | | _httpResponse.Dispose(); |
| | 4638 | | } |
| 0 | 4639 | | throw ex; |
| | 4640 | | } |
| | 4641 | | // Create Result |
| 0 | 4642 | | var _result = new HttpOperationResponse<HierarchicalEntityExtractor>(); |
| 0 | 4643 | | _result.Request = _httpRequest; |
| 0 | 4644 | | _result.Response = _httpResponse; |
| | 4645 | | // Deserialize Response |
| 0 | 4646 | | if ((int)_statusCode == 200) |
| | 4647 | | { |
| 0 | 4648 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 4649 | | try |
| | 4650 | | { |
| 0 | 4651 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<HierarchicalEntityExtractor>(_re |
| 0 | 4652 | | } |
| 0 | 4653 | | catch (JsonException ex) |
| | 4654 | | { |
| 0 | 4655 | | _httpRequest.Dispose(); |
| 0 | 4656 | | if (_httpResponse != null) |
| | 4657 | | { |
| 0 | 4658 | | _httpResponse.Dispose(); |
| | 4659 | | } |
| 0 | 4660 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 4661 | | } |
| | 4662 | | } |
| 0 | 4663 | | if (_shouldTrace) |
| | 4664 | | { |
| 0 | 4665 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 4666 | | } |
| 0 | 4667 | | return _result; |
| 0 | 4668 | | } |
| | 4669 | |
|
| | 4670 | | /// <summary> |
| | 4671 | | /// Updates the name of a hierarchical entity model in a version of the |
| | 4672 | | /// application. |
| | 4673 | | /// </summary> |
| | 4674 | | /// <param name='appId'> |
| | 4675 | | /// The application ID. |
| | 4676 | | /// </param> |
| | 4677 | | /// <param name='versionId'> |
| | 4678 | | /// The version ID. |
| | 4679 | | /// </param> |
| | 4680 | | /// <param name='hEntityId'> |
| | 4681 | | /// The hierarchical entity extractor ID. |
| | 4682 | | /// </param> |
| | 4683 | | /// <param name='modelUpdateObject'> |
| | 4684 | | /// Model containing names of the hierarchical entity. |
| | 4685 | | /// </param> |
| | 4686 | | /// <param name='customHeaders'> |
| | 4687 | | /// Headers that will be added to request. |
| | 4688 | | /// </param> |
| | 4689 | | /// <param name='cancellationToken'> |
| | 4690 | | /// The cancellation token. |
| | 4691 | | /// </param> |
| | 4692 | | /// <exception cref="ErrorResponseException"> |
| | 4693 | | /// Thrown when the operation returned an invalid status code |
| | 4694 | | /// </exception> |
| | 4695 | | /// <exception cref="SerializationException"> |
| | 4696 | | /// Thrown when unable to deserialize the response |
| | 4697 | | /// </exception> |
| | 4698 | | /// <exception cref="ValidationException"> |
| | 4699 | | /// Thrown when a required parameter is null |
| | 4700 | | /// </exception> |
| | 4701 | | /// <exception cref="System.ArgumentNullException"> |
| | 4702 | | /// Thrown when a required parameter is null |
| | 4703 | | /// </exception> |
| | 4704 | | /// <return> |
| | 4705 | | /// A response object containing the response body and response headers. |
| | 4706 | | /// </return> |
| | 4707 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateHierarchicalEntityWithHttpMessagesAsync(System.G |
| | 4708 | | { |
| 0 | 4709 | | if (Client.Endpoint == null) |
| | 4710 | | { |
| 0 | 4711 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 4712 | | } |
| 0 | 4713 | | if (versionId == null) |
| | 4714 | | { |
| 0 | 4715 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 4716 | | } |
| 0 | 4717 | | if (modelUpdateObject == null) |
| | 4718 | | { |
| 0 | 4719 | | throw new ValidationException(ValidationRules.CannotBeNull, "modelUpdateObject"); |
| | 4720 | | } |
| | 4721 | | // Tracing |
| 0 | 4722 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 4723 | | string _invocationId = null; |
| 0 | 4724 | | if (_shouldTrace) |
| | 4725 | | { |
| 0 | 4726 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 4727 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 4728 | | tracingParameters.Add("appId", appId); |
| 0 | 4729 | | tracingParameters.Add("versionId", versionId); |
| 0 | 4730 | | tracingParameters.Add("hEntityId", hEntityId); |
| 0 | 4731 | | tracingParameters.Add("modelUpdateObject", modelUpdateObject); |
| 0 | 4732 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 4733 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateHierarchicalEntity", tracingParameters); |
| | 4734 | | } |
| | 4735 | | // Construct URL |
| 0 | 4736 | | var _baseUrl = Client.BaseUri; |
| 0 | 4737 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale |
| 0 | 4738 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 4739 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 4740 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 4741 | | _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| | 4742 | | // Create HTTP transport objects |
| 0 | 4743 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 4744 | | HttpResponseMessage _httpResponse = null; |
| 0 | 4745 | | _httpRequest.Method = new HttpMethod("PATCH"); |
| 0 | 4746 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 4747 | | // Set Headers |
| | 4748 | |
|
| | 4749 | |
|
| 0 | 4750 | | if (customHeaders != null) |
| | 4751 | | { |
| 0 | 4752 | | foreach(var _header in customHeaders) |
| | 4753 | | { |
| 0 | 4754 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 4755 | | { |
| 0 | 4756 | | _httpRequest.Headers.Remove(_header.Key); |
| | 4757 | | } |
| 0 | 4758 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 4759 | | } |
| | 4760 | | } |
| | 4761 | |
|
| | 4762 | | // Serialize Request |
| 0 | 4763 | | string _requestContent = null; |
| 0 | 4764 | | if(modelUpdateObject != null) |
| | 4765 | | { |
| 0 | 4766 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(modelUpdateObject, Client.Serializa |
| 0 | 4767 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 4768 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 4769 | | } |
| | 4770 | | // Set Credentials |
| 0 | 4771 | | if (Client.Credentials != null) |
| | 4772 | | { |
| 0 | 4773 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 4774 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 4775 | | } |
| | 4776 | | // Send Request |
| 0 | 4777 | | if (_shouldTrace) |
| | 4778 | | { |
| 0 | 4779 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 4780 | | } |
| 0 | 4781 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 4782 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 4783 | | if (_shouldTrace) |
| | 4784 | | { |
| 0 | 4785 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 4786 | | } |
| 0 | 4787 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 4788 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 4789 | | string _responseContent = null; |
| 0 | 4790 | | if ((int)_statusCode != 200) |
| | 4791 | | { |
| 0 | 4792 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 4793 | | try |
| | 4794 | | { |
| 0 | 4795 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 4796 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 4797 | | if (_errorBody != null) |
| | 4798 | | { |
| 0 | 4799 | | ex.Body = _errorBody; |
| | 4800 | | } |
| 0 | 4801 | | } |
| 0 | 4802 | | catch (JsonException) |
| | 4803 | | { |
| | 4804 | | // Ignore the exception |
| 0 | 4805 | | } |
| 0 | 4806 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 4807 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 4808 | | if (_shouldTrace) |
| | 4809 | | { |
| 0 | 4810 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 4811 | | } |
| 0 | 4812 | | _httpRequest.Dispose(); |
| 0 | 4813 | | if (_httpResponse != null) |
| | 4814 | | { |
| 0 | 4815 | | _httpResponse.Dispose(); |
| | 4816 | | } |
| 0 | 4817 | | throw ex; |
| | 4818 | | } |
| | 4819 | | // Create Result |
| 0 | 4820 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 0 | 4821 | | _result.Request = _httpRequest; |
| 0 | 4822 | | _result.Response = _httpResponse; |
| | 4823 | | // Deserialize Response |
| 0 | 4824 | | if ((int)_statusCode == 200) |
| | 4825 | | { |
| 0 | 4826 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 4827 | | try |
| | 4828 | | { |
| 0 | 4829 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 0 | 4830 | | } |
| 0 | 4831 | | catch (JsonException ex) |
| | 4832 | | { |
| 0 | 4833 | | _httpRequest.Dispose(); |
| 0 | 4834 | | if (_httpResponse != null) |
| | 4835 | | { |
| 0 | 4836 | | _httpResponse.Dispose(); |
| | 4837 | | } |
| 0 | 4838 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 4839 | | } |
| | 4840 | | } |
| 0 | 4841 | | if (_shouldTrace) |
| | 4842 | | { |
| 0 | 4843 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 4844 | | } |
| 0 | 4845 | | return _result; |
| 0 | 4846 | | } |
| | 4847 | |
|
| | 4848 | | /// <summary> |
| | 4849 | | /// Deletes a hierarchical entity from a version of the application. |
| | 4850 | | /// </summary> |
| | 4851 | | /// <param name='appId'> |
| | 4852 | | /// The application ID. |
| | 4853 | | /// </param> |
| | 4854 | | /// <param name='versionId'> |
| | 4855 | | /// The version ID. |
| | 4856 | | /// </param> |
| | 4857 | | /// <param name='hEntityId'> |
| | 4858 | | /// The hierarchical entity extractor ID. |
| | 4859 | | /// </param> |
| | 4860 | | /// <param name='customHeaders'> |
| | 4861 | | /// Headers that will be added to request. |
| | 4862 | | /// </param> |
| | 4863 | | /// <param name='cancellationToken'> |
| | 4864 | | /// The cancellation token. |
| | 4865 | | /// </param> |
| | 4866 | | /// <exception cref="ErrorResponseException"> |
| | 4867 | | /// Thrown when the operation returned an invalid status code |
| | 4868 | | /// </exception> |
| | 4869 | | /// <exception cref="SerializationException"> |
| | 4870 | | /// Thrown when unable to deserialize the response |
| | 4871 | | /// </exception> |
| | 4872 | | /// <exception cref="ValidationException"> |
| | 4873 | | /// Thrown when a required parameter is null |
| | 4874 | | /// </exception> |
| | 4875 | | /// <exception cref="System.ArgumentNullException"> |
| | 4876 | | /// Thrown when a required parameter is null |
| | 4877 | | /// </exception> |
| | 4878 | | /// <return> |
| | 4879 | | /// A response object containing the response body and response headers. |
| | 4880 | | /// </return> |
| | 4881 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteHierarchicalEntityWithHttpMessagesAsync(System.G |
| | 4882 | | { |
| 0 | 4883 | | if (Client.Endpoint == null) |
| | 4884 | | { |
| 0 | 4885 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 4886 | | } |
| 0 | 4887 | | if (versionId == null) |
| | 4888 | | { |
| 0 | 4889 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 4890 | | } |
| | 4891 | | // Tracing |
| 0 | 4892 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 4893 | | string _invocationId = null; |
| 0 | 4894 | | if (_shouldTrace) |
| | 4895 | | { |
| 0 | 4896 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 4897 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 4898 | | tracingParameters.Add("appId", appId); |
| 0 | 4899 | | tracingParameters.Add("versionId", versionId); |
| 0 | 4900 | | tracingParameters.Add("hEntityId", hEntityId); |
| 0 | 4901 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 4902 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteHierarchicalEntity", tracingParameters); |
| | 4903 | | } |
| | 4904 | | // Construct URL |
| 0 | 4905 | | var _baseUrl = Client.BaseUri; |
| 0 | 4906 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale |
| 0 | 4907 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 4908 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 4909 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 4910 | | _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| | 4911 | | // Create HTTP transport objects |
| 0 | 4912 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 4913 | | HttpResponseMessage _httpResponse = null; |
| 0 | 4914 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 0 | 4915 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 4916 | | // Set Headers |
| | 4917 | |
|
| | 4918 | |
|
| 0 | 4919 | | if (customHeaders != null) |
| | 4920 | | { |
| 0 | 4921 | | foreach(var _header in customHeaders) |
| | 4922 | | { |
| 0 | 4923 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 4924 | | { |
| 0 | 4925 | | _httpRequest.Headers.Remove(_header.Key); |
| | 4926 | | } |
| 0 | 4927 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 4928 | | } |
| | 4929 | | } |
| | 4930 | |
|
| | 4931 | | // Serialize Request |
| 0 | 4932 | | string _requestContent = null; |
| | 4933 | | // Set Credentials |
| 0 | 4934 | | if (Client.Credentials != null) |
| | 4935 | | { |
| 0 | 4936 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 4937 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 4938 | | } |
| | 4939 | | // Send Request |
| 0 | 4940 | | if (_shouldTrace) |
| | 4941 | | { |
| 0 | 4942 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 4943 | | } |
| 0 | 4944 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 4945 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 4946 | | if (_shouldTrace) |
| | 4947 | | { |
| 0 | 4948 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 4949 | | } |
| 0 | 4950 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 4951 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 4952 | | string _responseContent = null; |
| 0 | 4953 | | if ((int)_statusCode != 200) |
| | 4954 | | { |
| 0 | 4955 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 4956 | | try |
| | 4957 | | { |
| 0 | 4958 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 4959 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 4960 | | if (_errorBody != null) |
| | 4961 | | { |
| 0 | 4962 | | ex.Body = _errorBody; |
| | 4963 | | } |
| 0 | 4964 | | } |
| 0 | 4965 | | catch (JsonException) |
| | 4966 | | { |
| | 4967 | | // Ignore the exception |
| 0 | 4968 | | } |
| 0 | 4969 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 4970 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 4971 | | if (_shouldTrace) |
| | 4972 | | { |
| 0 | 4973 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 4974 | | } |
| 0 | 4975 | | _httpRequest.Dispose(); |
| 0 | 4976 | | if (_httpResponse != null) |
| | 4977 | | { |
| 0 | 4978 | | _httpResponse.Dispose(); |
| | 4979 | | } |
| 0 | 4980 | | throw ex; |
| | 4981 | | } |
| | 4982 | | // Create Result |
| 0 | 4983 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 0 | 4984 | | _result.Request = _httpRequest; |
| 0 | 4985 | | _result.Response = _httpResponse; |
| | 4986 | | // Deserialize Response |
| 0 | 4987 | | if ((int)_statusCode == 200) |
| | 4988 | | { |
| 0 | 4989 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 4990 | | try |
| | 4991 | | { |
| 0 | 4992 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 0 | 4993 | | } |
| 0 | 4994 | | catch (JsonException ex) |
| | 4995 | | { |
| 0 | 4996 | | _httpRequest.Dispose(); |
| 0 | 4997 | | if (_httpResponse != null) |
| | 4998 | | { |
| 0 | 4999 | | _httpResponse.Dispose(); |
| | 5000 | | } |
| 0 | 5001 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 5002 | | } |
| | 5003 | | } |
| 0 | 5004 | | if (_shouldTrace) |
| | 5005 | | { |
| 0 | 5006 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 5007 | | } |
| 0 | 5008 | | return _result; |
| 0 | 5009 | | } |
| | 5010 | |
|
| | 5011 | | /// <summary> |
| | 5012 | | /// Gets information about a composite entity in a version of the application. |
| | 5013 | | /// </summary> |
| | 5014 | | /// <param name='appId'> |
| | 5015 | | /// The application ID. |
| | 5016 | | /// </param> |
| | 5017 | | /// <param name='versionId'> |
| | 5018 | | /// The version ID. |
| | 5019 | | /// </param> |
| | 5020 | | /// <param name='cEntityId'> |
| | 5021 | | /// The composite entity extractor ID. |
| | 5022 | | /// </param> |
| | 5023 | | /// <param name='customHeaders'> |
| | 5024 | | /// Headers that will be added to request. |
| | 5025 | | /// </param> |
| | 5026 | | /// <param name='cancellationToken'> |
| | 5027 | | /// The cancellation token. |
| | 5028 | | /// </param> |
| | 5029 | | /// <exception cref="ErrorResponseException"> |
| | 5030 | | /// Thrown when the operation returned an invalid status code |
| | 5031 | | /// </exception> |
| | 5032 | | /// <exception cref="SerializationException"> |
| | 5033 | | /// Thrown when unable to deserialize the response |
| | 5034 | | /// </exception> |
| | 5035 | | /// <exception cref="ValidationException"> |
| | 5036 | | /// Thrown when a required parameter is null |
| | 5037 | | /// </exception> |
| | 5038 | | /// <exception cref="System.ArgumentNullException"> |
| | 5039 | | /// Thrown when a required parameter is null |
| | 5040 | | /// </exception> |
| | 5041 | | /// <return> |
| | 5042 | | /// A response object containing the response body and response headers. |
| | 5043 | | /// </return> |
| | 5044 | | public async Task<HttpOperationResponse<CompositeEntityExtractor>> GetCompositeEntityWithHttpMessagesAsync(Syste |
| | 5045 | | { |
| 0 | 5046 | | if (Client.Endpoint == null) |
| | 5047 | | { |
| 0 | 5048 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 5049 | | } |
| 0 | 5050 | | if (versionId == null) |
| | 5051 | | { |
| 0 | 5052 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 5053 | | } |
| | 5054 | | // Tracing |
| 0 | 5055 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 5056 | | string _invocationId = null; |
| 0 | 5057 | | if (_shouldTrace) |
| | 5058 | | { |
| 0 | 5059 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 5060 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 5061 | | tracingParameters.Add("appId", appId); |
| 0 | 5062 | | tracingParameters.Add("versionId", versionId); |
| 0 | 5063 | | tracingParameters.Add("cEntityId", cEntityId); |
| 0 | 5064 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 5065 | | ServiceClientTracing.Enter(_invocationId, this, "GetCompositeEntity", tracingParameters); |
| | 5066 | | } |
| | 5067 | | // Construct URL |
| 0 | 5068 | | var _baseUrl = Client.BaseUri; |
| 0 | 5069 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti |
| 0 | 5070 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 5071 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 5072 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 5073 | | _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| | 5074 | | // Create HTTP transport objects |
| 0 | 5075 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 5076 | | HttpResponseMessage _httpResponse = null; |
| 0 | 5077 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 5078 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 5079 | | // Set Headers |
| | 5080 | |
|
| | 5081 | |
|
| 0 | 5082 | | if (customHeaders != null) |
| | 5083 | | { |
| 0 | 5084 | | foreach(var _header in customHeaders) |
| | 5085 | | { |
| 0 | 5086 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 5087 | | { |
| 0 | 5088 | | _httpRequest.Headers.Remove(_header.Key); |
| | 5089 | | } |
| 0 | 5090 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 5091 | | } |
| | 5092 | | } |
| | 5093 | |
|
| | 5094 | | // Serialize Request |
| 0 | 5095 | | string _requestContent = null; |
| | 5096 | | // Set Credentials |
| 0 | 5097 | | if (Client.Credentials != null) |
| | 5098 | | { |
| 0 | 5099 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 5100 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 5101 | | } |
| | 5102 | | // Send Request |
| 0 | 5103 | | if (_shouldTrace) |
| | 5104 | | { |
| 0 | 5105 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 5106 | | } |
| 0 | 5107 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 5108 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 5109 | | if (_shouldTrace) |
| | 5110 | | { |
| 0 | 5111 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 5112 | | } |
| 0 | 5113 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 5114 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 5115 | | string _responseContent = null; |
| 0 | 5116 | | if ((int)_statusCode != 200) |
| | 5117 | | { |
| 0 | 5118 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 5119 | | try |
| | 5120 | | { |
| 0 | 5121 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 5122 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 5123 | | if (_errorBody != null) |
| | 5124 | | { |
| 0 | 5125 | | ex.Body = _errorBody; |
| | 5126 | | } |
| 0 | 5127 | | } |
| 0 | 5128 | | catch (JsonException) |
| | 5129 | | { |
| | 5130 | | // Ignore the exception |
| 0 | 5131 | | } |
| 0 | 5132 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 5133 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 5134 | | if (_shouldTrace) |
| | 5135 | | { |
| 0 | 5136 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 5137 | | } |
| 0 | 5138 | | _httpRequest.Dispose(); |
| 0 | 5139 | | if (_httpResponse != null) |
| | 5140 | | { |
| 0 | 5141 | | _httpResponse.Dispose(); |
| | 5142 | | } |
| 0 | 5143 | | throw ex; |
| | 5144 | | } |
| | 5145 | | // Create Result |
| 0 | 5146 | | var _result = new HttpOperationResponse<CompositeEntityExtractor>(); |
| 0 | 5147 | | _result.Request = _httpRequest; |
| 0 | 5148 | | _result.Response = _httpResponse; |
| | 5149 | | // Deserialize Response |
| 0 | 5150 | | if ((int)_statusCode == 200) |
| | 5151 | | { |
| 0 | 5152 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 5153 | | try |
| | 5154 | | { |
| 0 | 5155 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<CompositeEntityExtractor>(_respo |
| 0 | 5156 | | } |
| 0 | 5157 | | catch (JsonException ex) |
| | 5158 | | { |
| 0 | 5159 | | _httpRequest.Dispose(); |
| 0 | 5160 | | if (_httpResponse != null) |
| | 5161 | | { |
| 0 | 5162 | | _httpResponse.Dispose(); |
| | 5163 | | } |
| 0 | 5164 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 5165 | | } |
| | 5166 | | } |
| 0 | 5167 | | if (_shouldTrace) |
| | 5168 | | { |
| 0 | 5169 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 5170 | | } |
| 0 | 5171 | | return _result; |
| 0 | 5172 | | } |
| | 5173 | |
|
| | 5174 | | /// <summary> |
| | 5175 | | /// Updates a composite entity in a version of the application. |
| | 5176 | | /// </summary> |
| | 5177 | | /// <param name='appId'> |
| | 5178 | | /// The application ID. |
| | 5179 | | /// </param> |
| | 5180 | | /// <param name='versionId'> |
| | 5181 | | /// The version ID. |
| | 5182 | | /// </param> |
| | 5183 | | /// <param name='cEntityId'> |
| | 5184 | | /// The composite entity extractor ID. |
| | 5185 | | /// </param> |
| | 5186 | | /// <param name='compositeModelUpdateObject'> |
| | 5187 | | /// A model object containing the new entity extractor name and children. |
| | 5188 | | /// </param> |
| | 5189 | | /// <param name='customHeaders'> |
| | 5190 | | /// Headers that will be added to request. |
| | 5191 | | /// </param> |
| | 5192 | | /// <param name='cancellationToken'> |
| | 5193 | | /// The cancellation token. |
| | 5194 | | /// </param> |
| | 5195 | | /// <exception cref="ErrorResponseException"> |
| | 5196 | | /// Thrown when the operation returned an invalid status code |
| | 5197 | | /// </exception> |
| | 5198 | | /// <exception cref="SerializationException"> |
| | 5199 | | /// Thrown when unable to deserialize the response |
| | 5200 | | /// </exception> |
| | 5201 | | /// <exception cref="ValidationException"> |
| | 5202 | | /// Thrown when a required parameter is null |
| | 5203 | | /// </exception> |
| | 5204 | | /// <exception cref="System.ArgumentNullException"> |
| | 5205 | | /// Thrown when a required parameter is null |
| | 5206 | | /// </exception> |
| | 5207 | | /// <return> |
| | 5208 | | /// A response object containing the response body and response headers. |
| | 5209 | | /// </return> |
| | 5210 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateCompositeEntityWithHttpMessagesAsync(System.Guid |
| | 5211 | | { |
| 0 | 5212 | | if (Client.Endpoint == null) |
| | 5213 | | { |
| 0 | 5214 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 5215 | | } |
| 0 | 5216 | | if (versionId == null) |
| | 5217 | | { |
| 0 | 5218 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 5219 | | } |
| 0 | 5220 | | if (compositeModelUpdateObject == null) |
| | 5221 | | { |
| 0 | 5222 | | throw new ValidationException(ValidationRules.CannotBeNull, "compositeModelUpdateObject"); |
| | 5223 | | } |
| | 5224 | | // Tracing |
| 0 | 5225 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 5226 | | string _invocationId = null; |
| 0 | 5227 | | if (_shouldTrace) |
| | 5228 | | { |
| 0 | 5229 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 5230 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 5231 | | tracingParameters.Add("appId", appId); |
| 0 | 5232 | | tracingParameters.Add("versionId", versionId); |
| 0 | 5233 | | tracingParameters.Add("cEntityId", cEntityId); |
| 0 | 5234 | | tracingParameters.Add("compositeModelUpdateObject", compositeModelUpdateObject); |
| 0 | 5235 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 5236 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateCompositeEntity", tracingParameters); |
| | 5237 | | } |
| | 5238 | | // Construct URL |
| 0 | 5239 | | var _baseUrl = Client.BaseUri; |
| 0 | 5240 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti |
| 0 | 5241 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 5242 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 5243 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 5244 | | _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| | 5245 | | // Create HTTP transport objects |
| 0 | 5246 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 5247 | | HttpResponseMessage _httpResponse = null; |
| 0 | 5248 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 0 | 5249 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 5250 | | // Set Headers |
| | 5251 | |
|
| | 5252 | |
|
| 0 | 5253 | | if (customHeaders != null) |
| | 5254 | | { |
| 0 | 5255 | | foreach(var _header in customHeaders) |
| | 5256 | | { |
| 0 | 5257 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 5258 | | { |
| 0 | 5259 | | _httpRequest.Headers.Remove(_header.Key); |
| | 5260 | | } |
| 0 | 5261 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 5262 | | } |
| | 5263 | | } |
| | 5264 | |
|
| | 5265 | | // Serialize Request |
| 0 | 5266 | | string _requestContent = null; |
| 0 | 5267 | | if(compositeModelUpdateObject != null) |
| | 5268 | | { |
| 0 | 5269 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(compositeModelUpdateObject, Client. |
| 0 | 5270 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 5271 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 5272 | | } |
| | 5273 | | // Set Credentials |
| 0 | 5274 | | if (Client.Credentials != null) |
| | 5275 | | { |
| 0 | 5276 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 5277 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 5278 | | } |
| | 5279 | | // Send Request |
| 0 | 5280 | | if (_shouldTrace) |
| | 5281 | | { |
| 0 | 5282 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 5283 | | } |
| 0 | 5284 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 5285 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 5286 | | if (_shouldTrace) |
| | 5287 | | { |
| 0 | 5288 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 5289 | | } |
| 0 | 5290 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 5291 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 5292 | | string _responseContent = null; |
| 0 | 5293 | | if ((int)_statusCode != 200) |
| | 5294 | | { |
| 0 | 5295 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 5296 | | try |
| | 5297 | | { |
| 0 | 5298 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 5299 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 5300 | | if (_errorBody != null) |
| | 5301 | | { |
| 0 | 5302 | | ex.Body = _errorBody; |
| | 5303 | | } |
| 0 | 5304 | | } |
| 0 | 5305 | | catch (JsonException) |
| | 5306 | | { |
| | 5307 | | // Ignore the exception |
| 0 | 5308 | | } |
| 0 | 5309 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 5310 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 5311 | | if (_shouldTrace) |
| | 5312 | | { |
| 0 | 5313 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 5314 | | } |
| 0 | 5315 | | _httpRequest.Dispose(); |
| 0 | 5316 | | if (_httpResponse != null) |
| | 5317 | | { |
| 0 | 5318 | | _httpResponse.Dispose(); |
| | 5319 | | } |
| 0 | 5320 | | throw ex; |
| | 5321 | | } |
| | 5322 | | // Create Result |
| 0 | 5323 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 0 | 5324 | | _result.Request = _httpRequest; |
| 0 | 5325 | | _result.Response = _httpResponse; |
| | 5326 | | // Deserialize Response |
| 0 | 5327 | | if ((int)_statusCode == 200) |
| | 5328 | | { |
| 0 | 5329 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 5330 | | try |
| | 5331 | | { |
| 0 | 5332 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 0 | 5333 | | } |
| 0 | 5334 | | catch (JsonException ex) |
| | 5335 | | { |
| 0 | 5336 | | _httpRequest.Dispose(); |
| 0 | 5337 | | if (_httpResponse != null) |
| | 5338 | | { |
| 0 | 5339 | | _httpResponse.Dispose(); |
| | 5340 | | } |
| 0 | 5341 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 5342 | | } |
| | 5343 | | } |
| 0 | 5344 | | if (_shouldTrace) |
| | 5345 | | { |
| 0 | 5346 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 5347 | | } |
| 0 | 5348 | | return _result; |
| 0 | 5349 | | } |
| | 5350 | |
|
| | 5351 | | /// <summary> |
| | 5352 | | /// Deletes a composite entity from a version of the application. |
| | 5353 | | /// </summary> |
| | 5354 | | /// <param name='appId'> |
| | 5355 | | /// The application ID. |
| | 5356 | | /// </param> |
| | 5357 | | /// <param name='versionId'> |
| | 5358 | | /// The version ID. |
| | 5359 | | /// </param> |
| | 5360 | | /// <param name='cEntityId'> |
| | 5361 | | /// The composite entity extractor ID. |
| | 5362 | | /// </param> |
| | 5363 | | /// <param name='customHeaders'> |
| | 5364 | | /// Headers that will be added to request. |
| | 5365 | | /// </param> |
| | 5366 | | /// <param name='cancellationToken'> |
| | 5367 | | /// The cancellation token. |
| | 5368 | | /// </param> |
| | 5369 | | /// <exception cref="ErrorResponseException"> |
| | 5370 | | /// Thrown when the operation returned an invalid status code |
| | 5371 | | /// </exception> |
| | 5372 | | /// <exception cref="SerializationException"> |
| | 5373 | | /// Thrown when unable to deserialize the response |
| | 5374 | | /// </exception> |
| | 5375 | | /// <exception cref="ValidationException"> |
| | 5376 | | /// Thrown when a required parameter is null |
| | 5377 | | /// </exception> |
| | 5378 | | /// <exception cref="System.ArgumentNullException"> |
| | 5379 | | /// Thrown when a required parameter is null |
| | 5380 | | /// </exception> |
| | 5381 | | /// <return> |
| | 5382 | | /// A response object containing the response body and response headers. |
| | 5383 | | /// </return> |
| | 5384 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteCompositeEntityWithHttpMessagesAsync(System.Guid |
| | 5385 | | { |
| 0 | 5386 | | if (Client.Endpoint == null) |
| | 5387 | | { |
| 0 | 5388 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 5389 | | } |
| 0 | 5390 | | if (versionId == null) |
| | 5391 | | { |
| 0 | 5392 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 5393 | | } |
| | 5394 | | // Tracing |
| 0 | 5395 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 5396 | | string _invocationId = null; |
| 0 | 5397 | | if (_shouldTrace) |
| | 5398 | | { |
| 0 | 5399 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 5400 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 5401 | | tracingParameters.Add("appId", appId); |
| 0 | 5402 | | tracingParameters.Add("versionId", versionId); |
| 0 | 5403 | | tracingParameters.Add("cEntityId", cEntityId); |
| 0 | 5404 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 5405 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteCompositeEntity", tracingParameters); |
| | 5406 | | } |
| | 5407 | | // Construct URL |
| 0 | 5408 | | var _baseUrl = Client.BaseUri; |
| 0 | 5409 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti |
| 0 | 5410 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 5411 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 5412 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 5413 | | _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| | 5414 | | // Create HTTP transport objects |
| 0 | 5415 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 5416 | | HttpResponseMessage _httpResponse = null; |
| 0 | 5417 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 0 | 5418 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 5419 | | // Set Headers |
| | 5420 | |
|
| | 5421 | |
|
| 0 | 5422 | | if (customHeaders != null) |
| | 5423 | | { |
| 0 | 5424 | | foreach(var _header in customHeaders) |
| | 5425 | | { |
| 0 | 5426 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 5427 | | { |
| 0 | 5428 | | _httpRequest.Headers.Remove(_header.Key); |
| | 5429 | | } |
| 0 | 5430 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 5431 | | } |
| | 5432 | | } |
| | 5433 | |
|
| | 5434 | | // Serialize Request |
| 0 | 5435 | | string _requestContent = null; |
| | 5436 | | // Set Credentials |
| 0 | 5437 | | if (Client.Credentials != null) |
| | 5438 | | { |
| 0 | 5439 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 5440 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 5441 | | } |
| | 5442 | | // Send Request |
| 0 | 5443 | | if (_shouldTrace) |
| | 5444 | | { |
| 0 | 5445 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 5446 | | } |
| 0 | 5447 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 5448 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 5449 | | if (_shouldTrace) |
| | 5450 | | { |
| 0 | 5451 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 5452 | | } |
| 0 | 5453 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 5454 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 5455 | | string _responseContent = null; |
| 0 | 5456 | | if ((int)_statusCode != 200) |
| | 5457 | | { |
| 0 | 5458 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 5459 | | try |
| | 5460 | | { |
| 0 | 5461 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 5462 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 5463 | | if (_errorBody != null) |
| | 5464 | | { |
| 0 | 5465 | | ex.Body = _errorBody; |
| | 5466 | | } |
| 0 | 5467 | | } |
| 0 | 5468 | | catch (JsonException) |
| | 5469 | | { |
| | 5470 | | // Ignore the exception |
| 0 | 5471 | | } |
| 0 | 5472 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 5473 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 5474 | | if (_shouldTrace) |
| | 5475 | | { |
| 0 | 5476 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 5477 | | } |
| 0 | 5478 | | _httpRequest.Dispose(); |
| 0 | 5479 | | if (_httpResponse != null) |
| | 5480 | | { |
| 0 | 5481 | | _httpResponse.Dispose(); |
| | 5482 | | } |
| 0 | 5483 | | throw ex; |
| | 5484 | | } |
| | 5485 | | // Create Result |
| 0 | 5486 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 0 | 5487 | | _result.Request = _httpRequest; |
| 0 | 5488 | | _result.Response = _httpResponse; |
| | 5489 | | // Deserialize Response |
| 0 | 5490 | | if ((int)_statusCode == 200) |
| | 5491 | | { |
| 0 | 5492 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 5493 | | try |
| | 5494 | | { |
| 0 | 5495 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 0 | 5496 | | } |
| 0 | 5497 | | catch (JsonException ex) |
| | 5498 | | { |
| 0 | 5499 | | _httpRequest.Dispose(); |
| 0 | 5500 | | if (_httpResponse != null) |
| | 5501 | | { |
| 0 | 5502 | | _httpResponse.Dispose(); |
| | 5503 | | } |
| 0 | 5504 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 5505 | | } |
| | 5506 | | } |
| 0 | 5507 | | if (_shouldTrace) |
| | 5508 | | { |
| 0 | 5509 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 5510 | | } |
| 0 | 5511 | | return _result; |
| 0 | 5512 | | } |
| | 5513 | |
|
| | 5514 | | /// <summary> |
| | 5515 | | /// Gets information about a list entity in a version of the application. |
| | 5516 | | /// </summary> |
| | 5517 | | /// <param name='appId'> |
| | 5518 | | /// The application ID. |
| | 5519 | | /// </param> |
| | 5520 | | /// <param name='versionId'> |
| | 5521 | | /// The version ID. |
| | 5522 | | /// </param> |
| | 5523 | | /// <param name='clEntityId'> |
| | 5524 | | /// The list model ID. |
| | 5525 | | /// </param> |
| | 5526 | | /// <param name='customHeaders'> |
| | 5527 | | /// Headers that will be added to request. |
| | 5528 | | /// </param> |
| | 5529 | | /// <param name='cancellationToken'> |
| | 5530 | | /// The cancellation token. |
| | 5531 | | /// </param> |
| | 5532 | | /// <exception cref="ErrorResponseException"> |
| | 5533 | | /// Thrown when the operation returned an invalid status code |
| | 5534 | | /// </exception> |
| | 5535 | | /// <exception cref="SerializationException"> |
| | 5536 | | /// Thrown when unable to deserialize the response |
| | 5537 | | /// </exception> |
| | 5538 | | /// <exception cref="ValidationException"> |
| | 5539 | | /// Thrown when a required parameter is null |
| | 5540 | | /// </exception> |
| | 5541 | | /// <exception cref="System.ArgumentNullException"> |
| | 5542 | | /// Thrown when a required parameter is null |
| | 5543 | | /// </exception> |
| | 5544 | | /// <return> |
| | 5545 | | /// A response object containing the response body and response headers. |
| | 5546 | | /// </return> |
| | 5547 | | public async Task<HttpOperationResponse<ClosedListEntityExtractor>> GetClosedListWithHttpMessagesAsync(System.Gu |
| | 5548 | | { |
| 8 | 5549 | | if (Client.Endpoint == null) |
| | 5550 | | { |
| 0 | 5551 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 5552 | | } |
| 8 | 5553 | | if (versionId == null) |
| | 5554 | | { |
| 0 | 5555 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 5556 | | } |
| | 5557 | | // Tracing |
| 8 | 5558 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 8 | 5559 | | string _invocationId = null; |
| 8 | 5560 | | if (_shouldTrace) |
| | 5561 | | { |
| 0 | 5562 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 5563 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 5564 | | tracingParameters.Add("appId", appId); |
| 0 | 5565 | | tracingParameters.Add("versionId", versionId); |
| 0 | 5566 | | tracingParameters.Add("clEntityId", clEntityId); |
| 0 | 5567 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 5568 | | ServiceClientTracing.Enter(_invocationId, this, "GetClosedList", tracingParameters); |
| | 5569 | | } |
| | 5570 | | // Construct URL |
| 8 | 5571 | | var _baseUrl = Client.BaseUri; |
| 8 | 5572 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{ |
| 8 | 5573 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 8 | 5574 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 8 | 5575 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 8 | 5576 | | _url = _url.Replace("{clEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize |
| | 5577 | | // Create HTTP transport objects |
| 8 | 5578 | | var _httpRequest = new HttpRequestMessage(); |
| 8 | 5579 | | HttpResponseMessage _httpResponse = null; |
| 8 | 5580 | | _httpRequest.Method = new HttpMethod("GET"); |
| 8 | 5581 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 5582 | | // Set Headers |
| | 5583 | |
|
| | 5584 | |
|
| 8 | 5585 | | if (customHeaders != null) |
| | 5586 | | { |
| 0 | 5587 | | foreach(var _header in customHeaders) |
| | 5588 | | { |
| 0 | 5589 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 5590 | | { |
| 0 | 5591 | | _httpRequest.Headers.Remove(_header.Key); |
| | 5592 | | } |
| 0 | 5593 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 5594 | | } |
| | 5595 | | } |
| | 5596 | |
|
| | 5597 | | // Serialize Request |
| 8 | 5598 | | string _requestContent = null; |
| | 5599 | | // Set Credentials |
| 8 | 5600 | | if (Client.Credentials != null) |
| | 5601 | | { |
| 8 | 5602 | | cancellationToken.ThrowIfCancellationRequested(); |
| 8 | 5603 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 5604 | | } |
| | 5605 | | // Send Request |
| 8 | 5606 | | if (_shouldTrace) |
| | 5607 | | { |
| 0 | 5608 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 5609 | | } |
| 8 | 5610 | | cancellationToken.ThrowIfCancellationRequested(); |
| 8 | 5611 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 8 | 5612 | | if (_shouldTrace) |
| | 5613 | | { |
| 0 | 5614 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 5615 | | } |
| 8 | 5616 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 8 | 5617 | | cancellationToken.ThrowIfCancellationRequested(); |
| 8 | 5618 | | string _responseContent = null; |
| 8 | 5619 | | if ((int)_statusCode != 200) |
| | 5620 | | { |
| 0 | 5621 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 5622 | | try |
| | 5623 | | { |
| 0 | 5624 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 5625 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 5626 | | if (_errorBody != null) |
| | 5627 | | { |
| 0 | 5628 | | ex.Body = _errorBody; |
| | 5629 | | } |
| 0 | 5630 | | } |
| 0 | 5631 | | catch (JsonException) |
| | 5632 | | { |
| | 5633 | | // Ignore the exception |
| 0 | 5634 | | } |
| 0 | 5635 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 5636 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 5637 | | if (_shouldTrace) |
| | 5638 | | { |
| 0 | 5639 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 5640 | | } |
| 0 | 5641 | | _httpRequest.Dispose(); |
| 0 | 5642 | | if (_httpResponse != null) |
| | 5643 | | { |
| 0 | 5644 | | _httpResponse.Dispose(); |
| | 5645 | | } |
| 0 | 5646 | | throw ex; |
| | 5647 | | } |
| | 5648 | | // Create Result |
| 8 | 5649 | | var _result = new HttpOperationResponse<ClosedListEntityExtractor>(); |
| 8 | 5650 | | _result.Request = _httpRequest; |
| 8 | 5651 | | _result.Response = _httpResponse; |
| | 5652 | | // Deserialize Response |
| 8 | 5653 | | if ((int)_statusCode == 200) |
| | 5654 | | { |
| 8 | 5655 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 5656 | | try |
| | 5657 | | { |
| 8 | 5658 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ClosedListEntityExtractor>(_resp |
| 8 | 5659 | | } |
| 0 | 5660 | | catch (JsonException ex) |
| | 5661 | | { |
| 0 | 5662 | | _httpRequest.Dispose(); |
| 0 | 5663 | | if (_httpResponse != null) |
| | 5664 | | { |
| 0 | 5665 | | _httpResponse.Dispose(); |
| | 5666 | | } |
| 0 | 5667 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 5668 | | } |
| | 5669 | | } |
| 8 | 5670 | | if (_shouldTrace) |
| | 5671 | | { |
| 0 | 5672 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 5673 | | } |
| 8 | 5674 | | return _result; |
| 8 | 5675 | | } |
| | 5676 | |
|
| | 5677 | | /// <summary> |
| | 5678 | | /// Updates the list entity in a version of the application. |
| | 5679 | | /// </summary> |
| | 5680 | | /// <param name='appId'> |
| | 5681 | | /// The application ID. |
| | 5682 | | /// </param> |
| | 5683 | | /// <param name='versionId'> |
| | 5684 | | /// The version ID. |
| | 5685 | | /// </param> |
| | 5686 | | /// <param name='clEntityId'> |
| | 5687 | | /// The list model ID. |
| | 5688 | | /// </param> |
| | 5689 | | /// <param name='closedListModelUpdateObject'> |
| | 5690 | | /// The new list entity name and words list. |
| | 5691 | | /// </param> |
| | 5692 | | /// <param name='customHeaders'> |
| | 5693 | | /// Headers that will be added to request. |
| | 5694 | | /// </param> |
| | 5695 | | /// <param name='cancellationToken'> |
| | 5696 | | /// The cancellation token. |
| | 5697 | | /// </param> |
| | 5698 | | /// <exception cref="ErrorResponseException"> |
| | 5699 | | /// Thrown when the operation returned an invalid status code |
| | 5700 | | /// </exception> |
| | 5701 | | /// <exception cref="SerializationException"> |
| | 5702 | | /// Thrown when unable to deserialize the response |
| | 5703 | | /// </exception> |
| | 5704 | | /// <exception cref="ValidationException"> |
| | 5705 | | /// Thrown when a required parameter is null |
| | 5706 | | /// </exception> |
| | 5707 | | /// <exception cref="System.ArgumentNullException"> |
| | 5708 | | /// Thrown when a required parameter is null |
| | 5709 | | /// </exception> |
| | 5710 | | /// <return> |
| | 5711 | | /// A response object containing the response body and response headers. |
| | 5712 | | /// </return> |
| | 5713 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateClosedListWithHttpMessagesAsync(System.Guid appI |
| | 5714 | | { |
| 1 | 5715 | | if (Client.Endpoint == null) |
| | 5716 | | { |
| 0 | 5717 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 5718 | | } |
| 1 | 5719 | | if (versionId == null) |
| | 5720 | | { |
| 0 | 5721 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 5722 | | } |
| 1 | 5723 | | if (closedListModelUpdateObject == null) |
| | 5724 | | { |
| 0 | 5725 | | throw new ValidationException(ValidationRules.CannotBeNull, "closedListModelUpdateObject"); |
| | 5726 | | } |
| | 5727 | | // Tracing |
| 1 | 5728 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 5729 | | string _invocationId = null; |
| 1 | 5730 | | if (_shouldTrace) |
| | 5731 | | { |
| 0 | 5732 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 5733 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 5734 | | tracingParameters.Add("appId", appId); |
| 0 | 5735 | | tracingParameters.Add("versionId", versionId); |
| 0 | 5736 | | tracingParameters.Add("clEntityId", clEntityId); |
| 0 | 5737 | | tracingParameters.Add("closedListModelUpdateObject", closedListModelUpdateObject); |
| 0 | 5738 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 5739 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateClosedList", tracingParameters); |
| | 5740 | | } |
| | 5741 | | // Construct URL |
| 1 | 5742 | | var _baseUrl = Client.BaseUri; |
| 1 | 5743 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{ |
| 1 | 5744 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 5745 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 5746 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 5747 | | _url = _url.Replace("{clEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize |
| | 5748 | | // Create HTTP transport objects |
| 1 | 5749 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 5750 | | HttpResponseMessage _httpResponse = null; |
| 1 | 5751 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 1 | 5752 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 5753 | | // Set Headers |
| | 5754 | |
|
| | 5755 | |
|
| 1 | 5756 | | if (customHeaders != null) |
| | 5757 | | { |
| 0 | 5758 | | foreach(var _header in customHeaders) |
| | 5759 | | { |
| 0 | 5760 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 5761 | | { |
| 0 | 5762 | | _httpRequest.Headers.Remove(_header.Key); |
| | 5763 | | } |
| 0 | 5764 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 5765 | | } |
| | 5766 | | } |
| | 5767 | |
|
| | 5768 | | // Serialize Request |
| 1 | 5769 | | string _requestContent = null; |
| 1 | 5770 | | if(closedListModelUpdateObject != null) |
| | 5771 | | { |
| 1 | 5772 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(closedListModelUpdateObject, Client |
| 1 | 5773 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 5774 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 5775 | | } |
| | 5776 | | // Set Credentials |
| 1 | 5777 | | if (Client.Credentials != null) |
| | 5778 | | { |
| 1 | 5779 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 5780 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 5781 | | } |
| | 5782 | | // Send Request |
| 1 | 5783 | | if (_shouldTrace) |
| | 5784 | | { |
| 0 | 5785 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 5786 | | } |
| 1 | 5787 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 5788 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 5789 | | if (_shouldTrace) |
| | 5790 | | { |
| 0 | 5791 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 5792 | | } |
| 1 | 5793 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 5794 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 5795 | | string _responseContent = null; |
| 1 | 5796 | | if ((int)_statusCode != 200) |
| | 5797 | | { |
| 0 | 5798 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 5799 | | try |
| | 5800 | | { |
| 0 | 5801 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 5802 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 5803 | | if (_errorBody != null) |
| | 5804 | | { |
| 0 | 5805 | | ex.Body = _errorBody; |
| | 5806 | | } |
| 0 | 5807 | | } |
| 0 | 5808 | | catch (JsonException) |
| | 5809 | | { |
| | 5810 | | // Ignore the exception |
| 0 | 5811 | | } |
| 0 | 5812 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 5813 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 5814 | | if (_shouldTrace) |
| | 5815 | | { |
| 0 | 5816 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 5817 | | } |
| 0 | 5818 | | _httpRequest.Dispose(); |
| 0 | 5819 | | if (_httpResponse != null) |
| | 5820 | | { |
| 0 | 5821 | | _httpResponse.Dispose(); |
| | 5822 | | } |
| 0 | 5823 | | throw ex; |
| | 5824 | | } |
| | 5825 | | // Create Result |
| 1 | 5826 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 5827 | | _result.Request = _httpRequest; |
| 1 | 5828 | | _result.Response = _httpResponse; |
| | 5829 | | // Deserialize Response |
| 1 | 5830 | | if ((int)_statusCode == 200) |
| | 5831 | | { |
| 1 | 5832 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 5833 | | try |
| | 5834 | | { |
| 1 | 5835 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 5836 | | } |
| 0 | 5837 | | catch (JsonException ex) |
| | 5838 | | { |
| 0 | 5839 | | _httpRequest.Dispose(); |
| 0 | 5840 | | if (_httpResponse != null) |
| | 5841 | | { |
| 0 | 5842 | | _httpResponse.Dispose(); |
| | 5843 | | } |
| 0 | 5844 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 5845 | | } |
| | 5846 | | } |
| 1 | 5847 | | if (_shouldTrace) |
| | 5848 | | { |
| 0 | 5849 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 5850 | | } |
| 1 | 5851 | | return _result; |
| 1 | 5852 | | } |
| | 5853 | |
|
| | 5854 | | /// <summary> |
| | 5855 | | /// Adds a batch of sublists to an existing list entity in a version of the |
| | 5856 | | /// application. |
| | 5857 | | /// </summary> |
| | 5858 | | /// <param name='appId'> |
| | 5859 | | /// The application ID. |
| | 5860 | | /// </param> |
| | 5861 | | /// <param name='versionId'> |
| | 5862 | | /// The version ID. |
| | 5863 | | /// </param> |
| | 5864 | | /// <param name='clEntityId'> |
| | 5865 | | /// The list entity model ID. |
| | 5866 | | /// </param> |
| | 5867 | | /// <param name='closedListModelPatchObject'> |
| | 5868 | | /// A words list batch. |
| | 5869 | | /// </param> |
| | 5870 | | /// <param name='customHeaders'> |
| | 5871 | | /// Headers that will be added to request. |
| | 5872 | | /// </param> |
| | 5873 | | /// <param name='cancellationToken'> |
| | 5874 | | /// The cancellation token. |
| | 5875 | | /// </param> |
| | 5876 | | /// <exception cref="ErrorResponseException"> |
| | 5877 | | /// Thrown when the operation returned an invalid status code |
| | 5878 | | /// </exception> |
| | 5879 | | /// <exception cref="SerializationException"> |
| | 5880 | | /// Thrown when unable to deserialize the response |
| | 5881 | | /// </exception> |
| | 5882 | | /// <exception cref="ValidationException"> |
| | 5883 | | /// Thrown when a required parameter is null |
| | 5884 | | /// </exception> |
| | 5885 | | /// <exception cref="System.ArgumentNullException"> |
| | 5886 | | /// Thrown when a required parameter is null |
| | 5887 | | /// </exception> |
| | 5888 | | /// <return> |
| | 5889 | | /// A response object containing the response body and response headers. |
| | 5890 | | /// </return> |
| | 5891 | | public async Task<HttpOperationResponse<OperationStatus>> PatchClosedListWithHttpMessagesAsync(System.Guid appId |
| | 5892 | | { |
| 1 | 5893 | | if (Client.Endpoint == null) |
| | 5894 | | { |
| 0 | 5895 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 5896 | | } |
| 1 | 5897 | | if (versionId == null) |
| | 5898 | | { |
| 0 | 5899 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 5900 | | } |
| 1 | 5901 | | if (closedListModelPatchObject == null) |
| | 5902 | | { |
| 0 | 5903 | | throw new ValidationException(ValidationRules.CannotBeNull, "closedListModelPatchObject"); |
| | 5904 | | } |
| | 5905 | | // Tracing |
| 1 | 5906 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 5907 | | string _invocationId = null; |
| 1 | 5908 | | if (_shouldTrace) |
| | 5909 | | { |
| 0 | 5910 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 5911 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 5912 | | tracingParameters.Add("appId", appId); |
| 0 | 5913 | | tracingParameters.Add("versionId", versionId); |
| 0 | 5914 | | tracingParameters.Add("clEntityId", clEntityId); |
| 0 | 5915 | | tracingParameters.Add("closedListModelPatchObject", closedListModelPatchObject); |
| 0 | 5916 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 5917 | | ServiceClientTracing.Enter(_invocationId, this, "PatchClosedList", tracingParameters); |
| | 5918 | | } |
| | 5919 | | // Construct URL |
| 1 | 5920 | | var _baseUrl = Client.BaseUri; |
| 1 | 5921 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{ |
| 1 | 5922 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 5923 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 5924 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 5925 | | _url = _url.Replace("{clEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize |
| | 5926 | | // Create HTTP transport objects |
| 1 | 5927 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 5928 | | HttpResponseMessage _httpResponse = null; |
| 1 | 5929 | | _httpRequest.Method = new HttpMethod("PATCH"); |
| 1 | 5930 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 5931 | | // Set Headers |
| | 5932 | |
|
| | 5933 | |
|
| 1 | 5934 | | if (customHeaders != null) |
| | 5935 | | { |
| 0 | 5936 | | foreach(var _header in customHeaders) |
| | 5937 | | { |
| 0 | 5938 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 5939 | | { |
| 0 | 5940 | | _httpRequest.Headers.Remove(_header.Key); |
| | 5941 | | } |
| 0 | 5942 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 5943 | | } |
| | 5944 | | } |
| | 5945 | |
|
| | 5946 | | // Serialize Request |
| 1 | 5947 | | string _requestContent = null; |
| 1 | 5948 | | if(closedListModelPatchObject != null) |
| | 5949 | | { |
| 1 | 5950 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(closedListModelPatchObject, Client. |
| 1 | 5951 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 5952 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 5953 | | } |
| | 5954 | | // Set Credentials |
| 1 | 5955 | | if (Client.Credentials != null) |
| | 5956 | | { |
| 1 | 5957 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 5958 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 5959 | | } |
| | 5960 | | // Send Request |
| 1 | 5961 | | if (_shouldTrace) |
| | 5962 | | { |
| 0 | 5963 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 5964 | | } |
| 1 | 5965 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 5966 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 5967 | | if (_shouldTrace) |
| | 5968 | | { |
| 0 | 5969 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 5970 | | } |
| 1 | 5971 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 5972 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 5973 | | string _responseContent = null; |
| 1 | 5974 | | if ((int)_statusCode != 200) |
| | 5975 | | { |
| 0 | 5976 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 5977 | | try |
| | 5978 | | { |
| 0 | 5979 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 5980 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 5981 | | if (_errorBody != null) |
| | 5982 | | { |
| 0 | 5983 | | ex.Body = _errorBody; |
| | 5984 | | } |
| 0 | 5985 | | } |
| 0 | 5986 | | catch (JsonException) |
| | 5987 | | { |
| | 5988 | | // Ignore the exception |
| 0 | 5989 | | } |
| 0 | 5990 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 5991 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 5992 | | if (_shouldTrace) |
| | 5993 | | { |
| 0 | 5994 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 5995 | | } |
| 0 | 5996 | | _httpRequest.Dispose(); |
| 0 | 5997 | | if (_httpResponse != null) |
| | 5998 | | { |
| 0 | 5999 | | _httpResponse.Dispose(); |
| | 6000 | | } |
| 0 | 6001 | | throw ex; |
| | 6002 | | } |
| | 6003 | | // Create Result |
| 1 | 6004 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 6005 | | _result.Request = _httpRequest; |
| 1 | 6006 | | _result.Response = _httpResponse; |
| | 6007 | | // Deserialize Response |
| 1 | 6008 | | if ((int)_statusCode == 200) |
| | 6009 | | { |
| 1 | 6010 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 6011 | | try |
| | 6012 | | { |
| 1 | 6013 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 6014 | | } |
| 0 | 6015 | | catch (JsonException ex) |
| | 6016 | | { |
| 0 | 6017 | | _httpRequest.Dispose(); |
| 0 | 6018 | | if (_httpResponse != null) |
| | 6019 | | { |
| 0 | 6020 | | _httpResponse.Dispose(); |
| | 6021 | | } |
| 0 | 6022 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 6023 | | } |
| | 6024 | | } |
| 1 | 6025 | | if (_shouldTrace) |
| | 6026 | | { |
| 0 | 6027 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 6028 | | } |
| 1 | 6029 | | return _result; |
| 1 | 6030 | | } |
| | 6031 | |
|
| | 6032 | | /// <summary> |
| | 6033 | | /// Deletes a list entity model from a version of the application. |
| | 6034 | | /// </summary> |
| | 6035 | | /// <param name='appId'> |
| | 6036 | | /// The application ID. |
| | 6037 | | /// </param> |
| | 6038 | | /// <param name='versionId'> |
| | 6039 | | /// The version ID. |
| | 6040 | | /// </param> |
| | 6041 | | /// <param name='clEntityId'> |
| | 6042 | | /// The list entity model ID. |
| | 6043 | | /// </param> |
| | 6044 | | /// <param name='customHeaders'> |
| | 6045 | | /// Headers that will be added to request. |
| | 6046 | | /// </param> |
| | 6047 | | /// <param name='cancellationToken'> |
| | 6048 | | /// The cancellation token. |
| | 6049 | | /// </param> |
| | 6050 | | /// <exception cref="ErrorResponseException"> |
| | 6051 | | /// Thrown when the operation returned an invalid status code |
| | 6052 | | /// </exception> |
| | 6053 | | /// <exception cref="SerializationException"> |
| | 6054 | | /// Thrown when unable to deserialize the response |
| | 6055 | | /// </exception> |
| | 6056 | | /// <exception cref="ValidationException"> |
| | 6057 | | /// Thrown when a required parameter is null |
| | 6058 | | /// </exception> |
| | 6059 | | /// <exception cref="System.ArgumentNullException"> |
| | 6060 | | /// Thrown when a required parameter is null |
| | 6061 | | /// </exception> |
| | 6062 | | /// <return> |
| | 6063 | | /// A response object containing the response body and response headers. |
| | 6064 | | /// </return> |
| | 6065 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteClosedListWithHttpMessagesAsync(System.Guid appI |
| | 6066 | | { |
| 14 | 6067 | | if (Client.Endpoint == null) |
| | 6068 | | { |
| 0 | 6069 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 6070 | | } |
| 14 | 6071 | | if (versionId == null) |
| | 6072 | | { |
| 0 | 6073 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 6074 | | } |
| | 6075 | | // Tracing |
| 14 | 6076 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 14 | 6077 | | string _invocationId = null; |
| 14 | 6078 | | if (_shouldTrace) |
| | 6079 | | { |
| 0 | 6080 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 6081 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 6082 | | tracingParameters.Add("appId", appId); |
| 0 | 6083 | | tracingParameters.Add("versionId", versionId); |
| 0 | 6084 | | tracingParameters.Add("clEntityId", clEntityId); |
| 0 | 6085 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 6086 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteClosedList", tracingParameters); |
| | 6087 | | } |
| | 6088 | | // Construct URL |
| 14 | 6089 | | var _baseUrl = Client.BaseUri; |
| 14 | 6090 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{ |
| 14 | 6091 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 14 | 6092 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 14 | 6093 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 14 | 6094 | | _url = _url.Replace("{clEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize |
| | 6095 | | // Create HTTP transport objects |
| 14 | 6096 | | var _httpRequest = new HttpRequestMessage(); |
| 14 | 6097 | | HttpResponseMessage _httpResponse = null; |
| 14 | 6098 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 14 | 6099 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 6100 | | // Set Headers |
| | 6101 | |
|
| | 6102 | |
|
| 14 | 6103 | | if (customHeaders != null) |
| | 6104 | | { |
| 0 | 6105 | | foreach(var _header in customHeaders) |
| | 6106 | | { |
| 0 | 6107 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 6108 | | { |
| 0 | 6109 | | _httpRequest.Headers.Remove(_header.Key); |
| | 6110 | | } |
| 0 | 6111 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 6112 | | } |
| | 6113 | | } |
| | 6114 | |
|
| | 6115 | | // Serialize Request |
| 14 | 6116 | | string _requestContent = null; |
| | 6117 | | // Set Credentials |
| 14 | 6118 | | if (Client.Credentials != null) |
| | 6119 | | { |
| 14 | 6120 | | cancellationToken.ThrowIfCancellationRequested(); |
| 14 | 6121 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 6122 | | } |
| | 6123 | | // Send Request |
| 14 | 6124 | | if (_shouldTrace) |
| | 6125 | | { |
| 0 | 6126 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 6127 | | } |
| 14 | 6128 | | cancellationToken.ThrowIfCancellationRequested(); |
| 14 | 6129 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 14 | 6130 | | if (_shouldTrace) |
| | 6131 | | { |
| 0 | 6132 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 6133 | | } |
| 14 | 6134 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 14 | 6135 | | cancellationToken.ThrowIfCancellationRequested(); |
| 14 | 6136 | | string _responseContent = null; |
| 14 | 6137 | | if ((int)_statusCode != 200) |
| | 6138 | | { |
| 0 | 6139 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 6140 | | try |
| | 6141 | | { |
| 0 | 6142 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 6143 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 6144 | | if (_errorBody != null) |
| | 6145 | | { |
| 0 | 6146 | | ex.Body = _errorBody; |
| | 6147 | | } |
| 0 | 6148 | | } |
| 0 | 6149 | | catch (JsonException) |
| | 6150 | | { |
| | 6151 | | // Ignore the exception |
| 0 | 6152 | | } |
| 0 | 6153 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 6154 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 6155 | | if (_shouldTrace) |
| | 6156 | | { |
| 0 | 6157 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 6158 | | } |
| 0 | 6159 | | _httpRequest.Dispose(); |
| 0 | 6160 | | if (_httpResponse != null) |
| | 6161 | | { |
| 0 | 6162 | | _httpResponse.Dispose(); |
| | 6163 | | } |
| 0 | 6164 | | throw ex; |
| | 6165 | | } |
| | 6166 | | // Create Result |
| 14 | 6167 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 14 | 6168 | | _result.Request = _httpRequest; |
| 14 | 6169 | | _result.Response = _httpResponse; |
| | 6170 | | // Deserialize Response |
| 14 | 6171 | | if ((int)_statusCode == 200) |
| | 6172 | | { |
| 14 | 6173 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 6174 | | try |
| | 6175 | | { |
| 14 | 6176 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 14 | 6177 | | } |
| 0 | 6178 | | catch (JsonException ex) |
| | 6179 | | { |
| 0 | 6180 | | _httpRequest.Dispose(); |
| 0 | 6181 | | if (_httpResponse != null) |
| | 6182 | | { |
| 0 | 6183 | | _httpResponse.Dispose(); |
| | 6184 | | } |
| 0 | 6185 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 6186 | | } |
| | 6187 | | } |
| 14 | 6188 | | if (_shouldTrace) |
| | 6189 | | { |
| 0 | 6190 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 6191 | | } |
| 14 | 6192 | | return _result; |
| 14 | 6193 | | } |
| | 6194 | |
|
| | 6195 | | /// <summary> |
| | 6196 | | /// Gets information about a prebuilt entity model in a version of the |
| | 6197 | | /// application. |
| | 6198 | | /// </summary> |
| | 6199 | | /// <param name='appId'> |
| | 6200 | | /// The application ID. |
| | 6201 | | /// </param> |
| | 6202 | | /// <param name='versionId'> |
| | 6203 | | /// The version ID. |
| | 6204 | | /// </param> |
| | 6205 | | /// <param name='prebuiltId'> |
| | 6206 | | /// The prebuilt entity extractor ID. |
| | 6207 | | /// </param> |
| | 6208 | | /// <param name='customHeaders'> |
| | 6209 | | /// Headers that will be added to request. |
| | 6210 | | /// </param> |
| | 6211 | | /// <param name='cancellationToken'> |
| | 6212 | | /// The cancellation token. |
| | 6213 | | /// </param> |
| | 6214 | | /// <exception cref="ErrorResponseException"> |
| | 6215 | | /// Thrown when the operation returned an invalid status code |
| | 6216 | | /// </exception> |
| | 6217 | | /// <exception cref="SerializationException"> |
| | 6218 | | /// Thrown when unable to deserialize the response |
| | 6219 | | /// </exception> |
| | 6220 | | /// <exception cref="ValidationException"> |
| | 6221 | | /// Thrown when a required parameter is null |
| | 6222 | | /// </exception> |
| | 6223 | | /// <exception cref="System.ArgumentNullException"> |
| | 6224 | | /// Thrown when a required parameter is null |
| | 6225 | | /// </exception> |
| | 6226 | | /// <return> |
| | 6227 | | /// A response object containing the response body and response headers. |
| | 6228 | | /// </return> |
| | 6229 | | public async Task<HttpOperationResponse<PrebuiltEntityExtractor>> GetPrebuiltWithHttpMessagesAsync(System.Guid a |
| | 6230 | | { |
| 1 | 6231 | | if (Client.Endpoint == null) |
| | 6232 | | { |
| 0 | 6233 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 6234 | | } |
| 1 | 6235 | | if (versionId == null) |
| | 6236 | | { |
| 0 | 6237 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 6238 | | } |
| | 6239 | | // Tracing |
| 1 | 6240 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 6241 | | string _invocationId = null; |
| 1 | 6242 | | if (_shouldTrace) |
| | 6243 | | { |
| 0 | 6244 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 6245 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 6246 | | tracingParameters.Add("appId", appId); |
| 0 | 6247 | | tracingParameters.Add("versionId", versionId); |
| 0 | 6248 | | tracingParameters.Add("prebuiltId", prebuiltId); |
| 0 | 6249 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 6250 | | ServiceClientTracing.Enter(_invocationId, this, "GetPrebuilt", tracingParameters); |
| | 6251 | | } |
| | 6252 | | // Construct URL |
| 1 | 6253 | | var _baseUrl = Client.BaseUri; |
| 1 | 6254 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts/{pr |
| 1 | 6255 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 6256 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 6257 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 6258 | | _url = _url.Replace("{prebuiltId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize |
| | 6259 | | // Create HTTP transport objects |
| 1 | 6260 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 6261 | | HttpResponseMessage _httpResponse = null; |
| 1 | 6262 | | _httpRequest.Method = new HttpMethod("GET"); |
| 1 | 6263 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 6264 | | // Set Headers |
| | 6265 | |
|
| | 6266 | |
|
| 1 | 6267 | | if (customHeaders != null) |
| | 6268 | | { |
| 0 | 6269 | | foreach(var _header in customHeaders) |
| | 6270 | | { |
| 0 | 6271 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 6272 | | { |
| 0 | 6273 | | _httpRequest.Headers.Remove(_header.Key); |
| | 6274 | | } |
| 0 | 6275 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 6276 | | } |
| | 6277 | | } |
| | 6278 | |
|
| | 6279 | | // Serialize Request |
| 1 | 6280 | | string _requestContent = null; |
| | 6281 | | // Set Credentials |
| 1 | 6282 | | if (Client.Credentials != null) |
| | 6283 | | { |
| 1 | 6284 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 6285 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 6286 | | } |
| | 6287 | | // Send Request |
| 1 | 6288 | | if (_shouldTrace) |
| | 6289 | | { |
| 0 | 6290 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 6291 | | } |
| 1 | 6292 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 6293 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 6294 | | if (_shouldTrace) |
| | 6295 | | { |
| 0 | 6296 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 6297 | | } |
| 1 | 6298 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 6299 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 6300 | | string _responseContent = null; |
| 1 | 6301 | | if ((int)_statusCode != 200) |
| | 6302 | | { |
| 0 | 6303 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 6304 | | try |
| | 6305 | | { |
| 0 | 6306 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 6307 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 6308 | | if (_errorBody != null) |
| | 6309 | | { |
| 0 | 6310 | | ex.Body = _errorBody; |
| | 6311 | | } |
| 0 | 6312 | | } |
| 0 | 6313 | | catch (JsonException) |
| | 6314 | | { |
| | 6315 | | // Ignore the exception |
| 0 | 6316 | | } |
| 0 | 6317 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 6318 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 6319 | | if (_shouldTrace) |
| | 6320 | | { |
| 0 | 6321 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 6322 | | } |
| 0 | 6323 | | _httpRequest.Dispose(); |
| 0 | 6324 | | if (_httpResponse != null) |
| | 6325 | | { |
| 0 | 6326 | | _httpResponse.Dispose(); |
| | 6327 | | } |
| 0 | 6328 | | throw ex; |
| | 6329 | | } |
| | 6330 | | // Create Result |
| 1 | 6331 | | var _result = new HttpOperationResponse<PrebuiltEntityExtractor>(); |
| 1 | 6332 | | _result.Request = _httpRequest; |
| 1 | 6333 | | _result.Response = _httpResponse; |
| | 6334 | | // Deserialize Response |
| 1 | 6335 | | if ((int)_statusCode == 200) |
| | 6336 | | { |
| 1 | 6337 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 6338 | | try |
| | 6339 | | { |
| 1 | 6340 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<PrebuiltEntityExtractor>(_respon |
| 1 | 6341 | | } |
| 0 | 6342 | | catch (JsonException ex) |
| | 6343 | | { |
| 0 | 6344 | | _httpRequest.Dispose(); |
| 0 | 6345 | | if (_httpResponse != null) |
| | 6346 | | { |
| 0 | 6347 | | _httpResponse.Dispose(); |
| | 6348 | | } |
| 0 | 6349 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 6350 | | } |
| | 6351 | | } |
| 1 | 6352 | | if (_shouldTrace) |
| | 6353 | | { |
| 0 | 6354 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 6355 | | } |
| 1 | 6356 | | return _result; |
| 1 | 6357 | | } |
| | 6358 | |
|
| | 6359 | | /// <summary> |
| | 6360 | | /// Deletes a prebuilt entity extractor from a version of the application. |
| | 6361 | | /// </summary> |
| | 6362 | | /// <param name='appId'> |
| | 6363 | | /// The application ID. |
| | 6364 | | /// </param> |
| | 6365 | | /// <param name='versionId'> |
| | 6366 | | /// The version ID. |
| | 6367 | | /// </param> |
| | 6368 | | /// <param name='prebuiltId'> |
| | 6369 | | /// The prebuilt entity extractor ID. |
| | 6370 | | /// </param> |
| | 6371 | | /// <param name='customHeaders'> |
| | 6372 | | /// Headers that will be added to request. |
| | 6373 | | /// </param> |
| | 6374 | | /// <param name='cancellationToken'> |
| | 6375 | | /// The cancellation token. |
| | 6376 | | /// </param> |
| | 6377 | | /// <exception cref="ErrorResponseException"> |
| | 6378 | | /// Thrown when the operation returned an invalid status code |
| | 6379 | | /// </exception> |
| | 6380 | | /// <exception cref="SerializationException"> |
| | 6381 | | /// Thrown when unable to deserialize the response |
| | 6382 | | /// </exception> |
| | 6383 | | /// <exception cref="ValidationException"> |
| | 6384 | | /// Thrown when a required parameter is null |
| | 6385 | | /// </exception> |
| | 6386 | | /// <exception cref="System.ArgumentNullException"> |
| | 6387 | | /// Thrown when a required parameter is null |
| | 6388 | | /// </exception> |
| | 6389 | | /// <return> |
| | 6390 | | /// A response object containing the response body and response headers. |
| | 6391 | | /// </return> |
| | 6392 | | public async Task<HttpOperationResponse<OperationStatus>> DeletePrebuiltWithHttpMessagesAsync(System.Guid appId, |
| | 6393 | | { |
| 26 | 6394 | | if (Client.Endpoint == null) |
| | 6395 | | { |
| 0 | 6396 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 6397 | | } |
| 26 | 6398 | | if (versionId == null) |
| | 6399 | | { |
| 0 | 6400 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 6401 | | } |
| | 6402 | | // Tracing |
| 26 | 6403 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 26 | 6404 | | string _invocationId = null; |
| 26 | 6405 | | if (_shouldTrace) |
| | 6406 | | { |
| 0 | 6407 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 6408 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 6409 | | tracingParameters.Add("appId", appId); |
| 0 | 6410 | | tracingParameters.Add("versionId", versionId); |
| 0 | 6411 | | tracingParameters.Add("prebuiltId", prebuiltId); |
| 0 | 6412 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 6413 | | ServiceClientTracing.Enter(_invocationId, this, "DeletePrebuilt", tracingParameters); |
| | 6414 | | } |
| | 6415 | | // Construct URL |
| 26 | 6416 | | var _baseUrl = Client.BaseUri; |
| 26 | 6417 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts/{pr |
| 26 | 6418 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 26 | 6419 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 26 | 6420 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 26 | 6421 | | _url = _url.Replace("{prebuiltId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize |
| | 6422 | | // Create HTTP transport objects |
| 26 | 6423 | | var _httpRequest = new HttpRequestMessage(); |
| 26 | 6424 | | HttpResponseMessage _httpResponse = null; |
| 26 | 6425 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 26 | 6426 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 6427 | | // Set Headers |
| | 6428 | |
|
| | 6429 | |
|
| 26 | 6430 | | if (customHeaders != null) |
| | 6431 | | { |
| 0 | 6432 | | foreach(var _header in customHeaders) |
| | 6433 | | { |
| 0 | 6434 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 6435 | | { |
| 0 | 6436 | | _httpRequest.Headers.Remove(_header.Key); |
| | 6437 | | } |
| 0 | 6438 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 6439 | | } |
| | 6440 | | } |
| | 6441 | |
|
| | 6442 | | // Serialize Request |
| 26 | 6443 | | string _requestContent = null; |
| | 6444 | | // Set Credentials |
| 26 | 6445 | | if (Client.Credentials != null) |
| | 6446 | | { |
| 26 | 6447 | | cancellationToken.ThrowIfCancellationRequested(); |
| 26 | 6448 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 6449 | | } |
| | 6450 | | // Send Request |
| 26 | 6451 | | if (_shouldTrace) |
| | 6452 | | { |
| 0 | 6453 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 6454 | | } |
| 26 | 6455 | | cancellationToken.ThrowIfCancellationRequested(); |
| 26 | 6456 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 26 | 6457 | | if (_shouldTrace) |
| | 6458 | | { |
| 0 | 6459 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 6460 | | } |
| 26 | 6461 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 26 | 6462 | | cancellationToken.ThrowIfCancellationRequested(); |
| 26 | 6463 | | string _responseContent = null; |
| 26 | 6464 | | if ((int)_statusCode != 200) |
| | 6465 | | { |
| 0 | 6466 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 6467 | | try |
| | 6468 | | { |
| 0 | 6469 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 6470 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 6471 | | if (_errorBody != null) |
| | 6472 | | { |
| 0 | 6473 | | ex.Body = _errorBody; |
| | 6474 | | } |
| 0 | 6475 | | } |
| 0 | 6476 | | catch (JsonException) |
| | 6477 | | { |
| | 6478 | | // Ignore the exception |
| 0 | 6479 | | } |
| 0 | 6480 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 6481 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 6482 | | if (_shouldTrace) |
| | 6483 | | { |
| 0 | 6484 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 6485 | | } |
| 0 | 6486 | | _httpRequest.Dispose(); |
| 0 | 6487 | | if (_httpResponse != null) |
| | 6488 | | { |
| 0 | 6489 | | _httpResponse.Dispose(); |
| | 6490 | | } |
| 0 | 6491 | | throw ex; |
| | 6492 | | } |
| | 6493 | | // Create Result |
| 26 | 6494 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 26 | 6495 | | _result.Request = _httpRequest; |
| 26 | 6496 | | _result.Response = _httpResponse; |
| | 6497 | | // Deserialize Response |
| 26 | 6498 | | if ((int)_statusCode == 200) |
| | 6499 | | { |
| 26 | 6500 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 6501 | | try |
| | 6502 | | { |
| 26 | 6503 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 26 | 6504 | | } |
| 0 | 6505 | | catch (JsonException ex) |
| | 6506 | | { |
| 0 | 6507 | | _httpRequest.Dispose(); |
| 0 | 6508 | | if (_httpResponse != null) |
| | 6509 | | { |
| 0 | 6510 | | _httpResponse.Dispose(); |
| | 6511 | | } |
| 0 | 6512 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 6513 | | } |
| | 6514 | | } |
| 26 | 6515 | | if (_shouldTrace) |
| | 6516 | | { |
| 0 | 6517 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 6518 | | } |
| 26 | 6519 | | return _result; |
| 26 | 6520 | | } |
| | 6521 | |
|
| | 6522 | | /// <summary> |
| | 6523 | | /// Deletes a sublist of a specific list entity model from a version of the |
| | 6524 | | /// application. |
| | 6525 | | /// </summary> |
| | 6526 | | /// <param name='appId'> |
| | 6527 | | /// The application ID. |
| | 6528 | | /// </param> |
| | 6529 | | /// <param name='versionId'> |
| | 6530 | | /// The version ID. |
| | 6531 | | /// </param> |
| | 6532 | | /// <param name='clEntityId'> |
| | 6533 | | /// The list entity extractor ID. |
| | 6534 | | /// </param> |
| | 6535 | | /// <param name='subListId'> |
| | 6536 | | /// The sublist ID. |
| | 6537 | | /// </param> |
| | 6538 | | /// <param name='customHeaders'> |
| | 6539 | | /// Headers that will be added to request. |
| | 6540 | | /// </param> |
| | 6541 | | /// <param name='cancellationToken'> |
| | 6542 | | /// The cancellation token. |
| | 6543 | | /// </param> |
| | 6544 | | /// <exception cref="ErrorResponseException"> |
| | 6545 | | /// Thrown when the operation returned an invalid status code |
| | 6546 | | /// </exception> |
| | 6547 | | /// <exception cref="SerializationException"> |
| | 6548 | | /// Thrown when unable to deserialize the response |
| | 6549 | | /// </exception> |
| | 6550 | | /// <exception cref="ValidationException"> |
| | 6551 | | /// Thrown when a required parameter is null |
| | 6552 | | /// </exception> |
| | 6553 | | /// <exception cref="System.ArgumentNullException"> |
| | 6554 | | /// Thrown when a required parameter is null |
| | 6555 | | /// </exception> |
| | 6556 | | /// <return> |
| | 6557 | | /// A response object containing the response body and response headers. |
| | 6558 | | /// </return> |
| | 6559 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteSubListWithHttpMessagesAsync(System.Guid appId, |
| | 6560 | | { |
| 1 | 6561 | | if (Client.Endpoint == null) |
| | 6562 | | { |
| 0 | 6563 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 6564 | | } |
| 1 | 6565 | | if (versionId == null) |
| | 6566 | | { |
| 0 | 6567 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 6568 | | } |
| | 6569 | | // Tracing |
| 1 | 6570 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 6571 | | string _invocationId = null; |
| 1 | 6572 | | if (_shouldTrace) |
| | 6573 | | { |
| 0 | 6574 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 6575 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 6576 | | tracingParameters.Add("appId", appId); |
| 0 | 6577 | | tracingParameters.Add("versionId", versionId); |
| 0 | 6578 | | tracingParameters.Add("clEntityId", clEntityId); |
| 0 | 6579 | | tracingParameters.Add("subListId", subListId); |
| 0 | 6580 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 6581 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteSubList", tracingParameters); |
| | 6582 | | } |
| | 6583 | | // Construct URL |
| 1 | 6584 | | var _baseUrl = Client.BaseUri; |
| 1 | 6585 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{ |
| 1 | 6586 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 6587 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 6588 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 6589 | | _url = _url.Replace("{clEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize |
| 1 | 6590 | | _url = _url.Replace("{subListId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| | 6591 | | // Create HTTP transport objects |
| 1 | 6592 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 6593 | | HttpResponseMessage _httpResponse = null; |
| 1 | 6594 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 1 | 6595 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 6596 | | // Set Headers |
| | 6597 | |
|
| | 6598 | |
|
| 1 | 6599 | | if (customHeaders != null) |
| | 6600 | | { |
| 0 | 6601 | | foreach(var _header in customHeaders) |
| | 6602 | | { |
| 0 | 6603 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 6604 | | { |
| 0 | 6605 | | _httpRequest.Headers.Remove(_header.Key); |
| | 6606 | | } |
| 0 | 6607 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 6608 | | } |
| | 6609 | | } |
| | 6610 | |
|
| | 6611 | | // Serialize Request |
| 1 | 6612 | | string _requestContent = null; |
| | 6613 | | // Set Credentials |
| 1 | 6614 | | if (Client.Credentials != null) |
| | 6615 | | { |
| 1 | 6616 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 6617 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 6618 | | } |
| | 6619 | | // Send Request |
| 1 | 6620 | | if (_shouldTrace) |
| | 6621 | | { |
| 0 | 6622 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 6623 | | } |
| 1 | 6624 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 6625 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 6626 | | if (_shouldTrace) |
| | 6627 | | { |
| 0 | 6628 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 6629 | | } |
| 1 | 6630 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 6631 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 6632 | | string _responseContent = null; |
| 1 | 6633 | | if ((int)_statusCode != 200) |
| | 6634 | | { |
| 0 | 6635 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 6636 | | try |
| | 6637 | | { |
| 0 | 6638 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 6639 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 6640 | | if (_errorBody != null) |
| | 6641 | | { |
| 0 | 6642 | | ex.Body = _errorBody; |
| | 6643 | | } |
| 0 | 6644 | | } |
| 0 | 6645 | | catch (JsonException) |
| | 6646 | | { |
| | 6647 | | // Ignore the exception |
| 0 | 6648 | | } |
| 0 | 6649 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 6650 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 6651 | | if (_shouldTrace) |
| | 6652 | | { |
| 0 | 6653 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 6654 | | } |
| 0 | 6655 | | _httpRequest.Dispose(); |
| 0 | 6656 | | if (_httpResponse != null) |
| | 6657 | | { |
| 0 | 6658 | | _httpResponse.Dispose(); |
| | 6659 | | } |
| 0 | 6660 | | throw ex; |
| | 6661 | | } |
| | 6662 | | // Create Result |
| 1 | 6663 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 6664 | | _result.Request = _httpRequest; |
| 1 | 6665 | | _result.Response = _httpResponse; |
| | 6666 | | // Deserialize Response |
| 1 | 6667 | | if ((int)_statusCode == 200) |
| | 6668 | | { |
| 1 | 6669 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 6670 | | try |
| | 6671 | | { |
| 1 | 6672 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 6673 | | } |
| 0 | 6674 | | catch (JsonException ex) |
| | 6675 | | { |
| 0 | 6676 | | _httpRequest.Dispose(); |
| 0 | 6677 | | if (_httpResponse != null) |
| | 6678 | | { |
| 0 | 6679 | | _httpResponse.Dispose(); |
| | 6680 | | } |
| 0 | 6681 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 6682 | | } |
| | 6683 | | } |
| 1 | 6684 | | if (_shouldTrace) |
| | 6685 | | { |
| 0 | 6686 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 6687 | | } |
| 1 | 6688 | | return _result; |
| 1 | 6689 | | } |
| | 6690 | |
|
| | 6691 | | /// <summary> |
| | 6692 | | /// Updates one of the list entity's sublists in a version of the application. |
| | 6693 | | /// </summary> |
| | 6694 | | /// <param name='appId'> |
| | 6695 | | /// The application ID. |
| | 6696 | | /// </param> |
| | 6697 | | /// <param name='versionId'> |
| | 6698 | | /// The version ID. |
| | 6699 | | /// </param> |
| | 6700 | | /// <param name='clEntityId'> |
| | 6701 | | /// The list entity extractor ID. |
| | 6702 | | /// </param> |
| | 6703 | | /// <param name='subListId'> |
| | 6704 | | /// The sublist ID. |
| | 6705 | | /// </param> |
| | 6706 | | /// <param name='wordListBaseUpdateObject'> |
| | 6707 | | /// A sublist update object containing the new canonical form and the list of |
| | 6708 | | /// words. |
| | 6709 | | /// </param> |
| | 6710 | | /// <param name='customHeaders'> |
| | 6711 | | /// Headers that will be added to request. |
| | 6712 | | /// </param> |
| | 6713 | | /// <param name='cancellationToken'> |
| | 6714 | | /// The cancellation token. |
| | 6715 | | /// </param> |
| | 6716 | | /// <exception cref="ErrorResponseException"> |
| | 6717 | | /// Thrown when the operation returned an invalid status code |
| | 6718 | | /// </exception> |
| | 6719 | | /// <exception cref="SerializationException"> |
| | 6720 | | /// Thrown when unable to deserialize the response |
| | 6721 | | /// </exception> |
| | 6722 | | /// <exception cref="ValidationException"> |
| | 6723 | | /// Thrown when a required parameter is null |
| | 6724 | | /// </exception> |
| | 6725 | | /// <exception cref="System.ArgumentNullException"> |
| | 6726 | | /// Thrown when a required parameter is null |
| | 6727 | | /// </exception> |
| | 6728 | | /// <return> |
| | 6729 | | /// A response object containing the response body and response headers. |
| | 6730 | | /// </return> |
| | 6731 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateSubListWithHttpMessagesAsync(System.Guid appId, |
| | 6732 | | { |
| 1 | 6733 | | if (Client.Endpoint == null) |
| | 6734 | | { |
| 0 | 6735 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 6736 | | } |
| 1 | 6737 | | if (versionId == null) |
| | 6738 | | { |
| 0 | 6739 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 6740 | | } |
| 1 | 6741 | | if (wordListBaseUpdateObject == null) |
| | 6742 | | { |
| 0 | 6743 | | throw new ValidationException(ValidationRules.CannotBeNull, "wordListBaseUpdateObject"); |
| | 6744 | | } |
| | 6745 | | // Tracing |
| 1 | 6746 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 6747 | | string _invocationId = null; |
| 1 | 6748 | | if (_shouldTrace) |
| | 6749 | | { |
| 0 | 6750 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 6751 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 6752 | | tracingParameters.Add("appId", appId); |
| 0 | 6753 | | tracingParameters.Add("versionId", versionId); |
| 0 | 6754 | | tracingParameters.Add("clEntityId", clEntityId); |
| 0 | 6755 | | tracingParameters.Add("subListId", subListId); |
| 0 | 6756 | | tracingParameters.Add("wordListBaseUpdateObject", wordListBaseUpdateObject); |
| 0 | 6757 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 6758 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateSubList", tracingParameters); |
| | 6759 | | } |
| | 6760 | | // Construct URL |
| 1 | 6761 | | var _baseUrl = Client.BaseUri; |
| 1 | 6762 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{ |
| 1 | 6763 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 6764 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 6765 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 6766 | | _url = _url.Replace("{clEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize |
| 1 | 6767 | | _url = _url.Replace("{subListId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| | 6768 | | // Create HTTP transport objects |
| 1 | 6769 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 6770 | | HttpResponseMessage _httpResponse = null; |
| 1 | 6771 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 1 | 6772 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 6773 | | // Set Headers |
| | 6774 | |
|
| | 6775 | |
|
| 1 | 6776 | | if (customHeaders != null) |
| | 6777 | | { |
| 0 | 6778 | | foreach(var _header in customHeaders) |
| | 6779 | | { |
| 0 | 6780 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 6781 | | { |
| 0 | 6782 | | _httpRequest.Headers.Remove(_header.Key); |
| | 6783 | | } |
| 0 | 6784 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 6785 | | } |
| | 6786 | | } |
| | 6787 | |
|
| | 6788 | | // Serialize Request |
| 1 | 6789 | | string _requestContent = null; |
| 1 | 6790 | | if(wordListBaseUpdateObject != null) |
| | 6791 | | { |
| 1 | 6792 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(wordListBaseUpdateObject, Client.Se |
| 1 | 6793 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 6794 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 6795 | | } |
| | 6796 | | // Set Credentials |
| 1 | 6797 | | if (Client.Credentials != null) |
| | 6798 | | { |
| 1 | 6799 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 6800 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 6801 | | } |
| | 6802 | | // Send Request |
| 1 | 6803 | | if (_shouldTrace) |
| | 6804 | | { |
| 0 | 6805 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 6806 | | } |
| 1 | 6807 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 6808 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 6809 | | if (_shouldTrace) |
| | 6810 | | { |
| 0 | 6811 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 6812 | | } |
| 1 | 6813 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 6814 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 6815 | | string _responseContent = null; |
| 1 | 6816 | | if ((int)_statusCode != 200) |
| | 6817 | | { |
| 0 | 6818 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 6819 | | try |
| | 6820 | | { |
| 0 | 6821 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 6822 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 6823 | | if (_errorBody != null) |
| | 6824 | | { |
| 0 | 6825 | | ex.Body = _errorBody; |
| | 6826 | | } |
| 0 | 6827 | | } |
| 0 | 6828 | | catch (JsonException) |
| | 6829 | | { |
| | 6830 | | // Ignore the exception |
| 0 | 6831 | | } |
| 0 | 6832 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 6833 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 6834 | | if (_shouldTrace) |
| | 6835 | | { |
| 0 | 6836 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 6837 | | } |
| 0 | 6838 | | _httpRequest.Dispose(); |
| 0 | 6839 | | if (_httpResponse != null) |
| | 6840 | | { |
| 0 | 6841 | | _httpResponse.Dispose(); |
| | 6842 | | } |
| 0 | 6843 | | throw ex; |
| | 6844 | | } |
| | 6845 | | // Create Result |
| 1 | 6846 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 6847 | | _result.Request = _httpRequest; |
| 1 | 6848 | | _result.Response = _httpResponse; |
| | 6849 | | // Deserialize Response |
| 1 | 6850 | | if ((int)_statusCode == 200) |
| | 6851 | | { |
| 1 | 6852 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 6853 | | try |
| | 6854 | | { |
| 1 | 6855 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 6856 | | } |
| 0 | 6857 | | catch (JsonException ex) |
| | 6858 | | { |
| 0 | 6859 | | _httpRequest.Dispose(); |
| 0 | 6860 | | if (_httpResponse != null) |
| | 6861 | | { |
| 0 | 6862 | | _httpResponse.Dispose(); |
| | 6863 | | } |
| 0 | 6864 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 6865 | | } |
| | 6866 | | } |
| 1 | 6867 | | if (_shouldTrace) |
| | 6868 | | { |
| 0 | 6869 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 6870 | | } |
| 1 | 6871 | | return _result; |
| 1 | 6872 | | } |
| | 6873 | |
|
| | 6874 | | /// <summary> |
| | 6875 | | /// Suggests example utterances that would improve the accuracy of the intent |
| | 6876 | | /// model in a version of the application. |
| | 6877 | | /// </summary> |
| | 6878 | | /// <param name='appId'> |
| | 6879 | | /// The application ID. |
| | 6880 | | /// </param> |
| | 6881 | | /// <param name='versionId'> |
| | 6882 | | /// The version ID. |
| | 6883 | | /// </param> |
| | 6884 | | /// <param name='intentId'> |
| | 6885 | | /// The intent classifier ID. |
| | 6886 | | /// </param> |
| | 6887 | | /// <param name='take'> |
| | 6888 | | /// The number of entries to return. Maximum page size is 500. Default is 100. |
| | 6889 | | /// </param> |
| | 6890 | | /// <param name='enableNestedChildren'> |
| | 6891 | | /// Toggles nested/flat format |
| | 6892 | | /// </param> |
| | 6893 | | /// <param name='customHeaders'> |
| | 6894 | | /// Headers that will be added to request. |
| | 6895 | | /// </param> |
| | 6896 | | /// <param name='cancellationToken'> |
| | 6897 | | /// The cancellation token. |
| | 6898 | | /// </param> |
| | 6899 | | /// <exception cref="ErrorResponseException"> |
| | 6900 | | /// Thrown when the operation returned an invalid status code |
| | 6901 | | /// </exception> |
| | 6902 | | /// <exception cref="SerializationException"> |
| | 6903 | | /// Thrown when unable to deserialize the response |
| | 6904 | | /// </exception> |
| | 6905 | | /// <exception cref="ValidationException"> |
| | 6906 | | /// Thrown when a required parameter is null |
| | 6907 | | /// </exception> |
| | 6908 | | /// <exception cref="System.ArgumentNullException"> |
| | 6909 | | /// Thrown when a required parameter is null |
| | 6910 | | /// </exception> |
| | 6911 | | /// <return> |
| | 6912 | | /// A response object containing the response body and response headers. |
| | 6913 | | /// </return> |
| | 6914 | | public async Task<HttpOperationResponse<IList<IntentsSuggestionExample>>> ListIntentSuggestionsWithHttpMessagesA |
| | 6915 | | { |
| 0 | 6916 | | if (Client.Endpoint == null) |
| | 6917 | | { |
| 0 | 6918 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 6919 | | } |
| 0 | 6920 | | if (versionId == null) |
| | 6921 | | { |
| 0 | 6922 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 6923 | | } |
| 0 | 6924 | | if (take > 500) |
| | 6925 | | { |
| 0 | 6926 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500); |
| | 6927 | | } |
| 0 | 6928 | | if (take < 0) |
| | 6929 | | { |
| 0 | 6930 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0); |
| | 6931 | | } |
| | 6932 | | // Tracing |
| 0 | 6933 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 6934 | | string _invocationId = null; |
| 0 | 6935 | | if (_shouldTrace) |
| | 6936 | | { |
| 0 | 6937 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 6938 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 6939 | | tracingParameters.Add("appId", appId); |
| 0 | 6940 | | tracingParameters.Add("versionId", versionId); |
| 0 | 6941 | | tracingParameters.Add("intentId", intentId); |
| 0 | 6942 | | tracingParameters.Add("take", take); |
| 0 | 6943 | | tracingParameters.Add("enableNestedChildren", enableNestedChildren); |
| 0 | 6944 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 6945 | | ServiceClientTracing.Enter(_invocationId, this, "ListIntentSuggestions", tracingParameters); |
| | 6946 | | } |
| | 6947 | | // Construct URL |
| 0 | 6948 | | var _baseUrl = Client.BaseUri; |
| 0 | 6949 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/intents/{inte |
| 0 | 6950 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 6951 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 6952 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 6953 | | _url = _url.Replace("{intentId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 0 | 6954 | | List<string> _queryParameters = new List<string>(); |
| 0 | 6955 | | if (take != null) |
| | 6956 | | { |
| 0 | 6957 | | _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 6958 | | } |
| 0 | 6959 | | if (enableNestedChildren != null) |
| | 6960 | | { |
| 0 | 6961 | | _queryParameters.Add(string.Format("enableNestedChildren={0}", System.Uri.EscapeDataString(Rest.Serializ |
| | 6962 | | } |
| 0 | 6963 | | if (_queryParameters.Count > 0) |
| | 6964 | | { |
| 0 | 6965 | | _url += "?" + string.Join("&", _queryParameters); |
| | 6966 | | } |
| | 6967 | | // Create HTTP transport objects |
| 0 | 6968 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 6969 | | HttpResponseMessage _httpResponse = null; |
| 0 | 6970 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 6971 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 6972 | | // Set Headers |
| | 6973 | |
|
| | 6974 | |
|
| 0 | 6975 | | if (customHeaders != null) |
| | 6976 | | { |
| 0 | 6977 | | foreach(var _header in customHeaders) |
| | 6978 | | { |
| 0 | 6979 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 6980 | | { |
| 0 | 6981 | | _httpRequest.Headers.Remove(_header.Key); |
| | 6982 | | } |
| 0 | 6983 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 6984 | | } |
| | 6985 | | } |
| | 6986 | |
|
| | 6987 | | // Serialize Request |
| 0 | 6988 | | string _requestContent = null; |
| | 6989 | | // Set Credentials |
| 0 | 6990 | | if (Client.Credentials != null) |
| | 6991 | | { |
| 0 | 6992 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 6993 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 6994 | | } |
| | 6995 | | // Send Request |
| 0 | 6996 | | if (_shouldTrace) |
| | 6997 | | { |
| 0 | 6998 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 6999 | | } |
| 0 | 7000 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 7001 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 7002 | | if (_shouldTrace) |
| | 7003 | | { |
| 0 | 7004 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 7005 | | } |
| 0 | 7006 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 7007 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 7008 | | string _responseContent = null; |
| 0 | 7009 | | if ((int)_statusCode != 200) |
| | 7010 | | { |
| 0 | 7011 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 7012 | | try |
| | 7013 | | { |
| 0 | 7014 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 7015 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 7016 | | if (_errorBody != null) |
| | 7017 | | { |
| 0 | 7018 | | ex.Body = _errorBody; |
| | 7019 | | } |
| 0 | 7020 | | } |
| 0 | 7021 | | catch (JsonException) |
| | 7022 | | { |
| | 7023 | | // Ignore the exception |
| 0 | 7024 | | } |
| 0 | 7025 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 7026 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 7027 | | if (_shouldTrace) |
| | 7028 | | { |
| 0 | 7029 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 7030 | | } |
| 0 | 7031 | | _httpRequest.Dispose(); |
| 0 | 7032 | | if (_httpResponse != null) |
| | 7033 | | { |
| 0 | 7034 | | _httpResponse.Dispose(); |
| | 7035 | | } |
| 0 | 7036 | | throw ex; |
| | 7037 | | } |
| | 7038 | | // Create Result |
| 0 | 7039 | | var _result = new HttpOperationResponse<IList<IntentsSuggestionExample>>(); |
| 0 | 7040 | | _result.Request = _httpRequest; |
| 0 | 7041 | | _result.Response = _httpResponse; |
| | 7042 | | // Deserialize Response |
| 0 | 7043 | | if ((int)_statusCode == 200) |
| | 7044 | | { |
| 0 | 7045 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 7046 | | try |
| | 7047 | | { |
| 0 | 7048 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<IntentsSuggestionExample>> |
| 0 | 7049 | | } |
| 0 | 7050 | | catch (JsonException ex) |
| | 7051 | | { |
| 0 | 7052 | | _httpRequest.Dispose(); |
| 0 | 7053 | | if (_httpResponse != null) |
| | 7054 | | { |
| 0 | 7055 | | _httpResponse.Dispose(); |
| | 7056 | | } |
| 0 | 7057 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 7058 | | } |
| | 7059 | | } |
| 0 | 7060 | | if (_shouldTrace) |
| | 7061 | | { |
| 0 | 7062 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 7063 | | } |
| 0 | 7064 | | return _result; |
| 0 | 7065 | | } |
| | 7066 | |
|
| | 7067 | | /// <summary> |
| | 7068 | | /// Get suggested example utterances that would improve the accuracy of the |
| | 7069 | | /// entity model in a version of the application. |
| | 7070 | | /// </summary> |
| | 7071 | | /// <param name='appId'> |
| | 7072 | | /// The application ID. |
| | 7073 | | /// </param> |
| | 7074 | | /// <param name='versionId'> |
| | 7075 | | /// The version ID. |
| | 7076 | | /// </param> |
| | 7077 | | /// <param name='entityId'> |
| | 7078 | | /// The target entity extractor model to enhance. |
| | 7079 | | /// </param> |
| | 7080 | | /// <param name='take'> |
| | 7081 | | /// The number of entries to return. Maximum page size is 500. Default is 100. |
| | 7082 | | /// </param> |
| | 7083 | | /// <param name='enableNestedChildren'> |
| | 7084 | | /// Toggles nested/flat format |
| | 7085 | | /// </param> |
| | 7086 | | /// <param name='customHeaders'> |
| | 7087 | | /// Headers that will be added to request. |
| | 7088 | | /// </param> |
| | 7089 | | /// <param name='cancellationToken'> |
| | 7090 | | /// The cancellation token. |
| | 7091 | | /// </param> |
| | 7092 | | /// <exception cref="ErrorResponseException"> |
| | 7093 | | /// Thrown when the operation returned an invalid status code |
| | 7094 | | /// </exception> |
| | 7095 | | /// <exception cref="SerializationException"> |
| | 7096 | | /// Thrown when unable to deserialize the response |
| | 7097 | | /// </exception> |
| | 7098 | | /// <exception cref="ValidationException"> |
| | 7099 | | /// Thrown when a required parameter is null |
| | 7100 | | /// </exception> |
| | 7101 | | /// <exception cref="System.ArgumentNullException"> |
| | 7102 | | /// Thrown when a required parameter is null |
| | 7103 | | /// </exception> |
| | 7104 | | /// <return> |
| | 7105 | | /// A response object containing the response body and response headers. |
| | 7106 | | /// </return> |
| | 7107 | | public async Task<HttpOperationResponse<IList<EntitiesSuggestionExample>>> ListEntitySuggestionsWithHttpMessages |
| | 7108 | | { |
| 1 | 7109 | | if (Client.Endpoint == null) |
| | 7110 | | { |
| 0 | 7111 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 7112 | | } |
| 1 | 7113 | | if (versionId == null) |
| | 7114 | | { |
| 0 | 7115 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 7116 | | } |
| 1 | 7117 | | if (take > 500) |
| | 7118 | | { |
| 0 | 7119 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500); |
| | 7120 | | } |
| 1 | 7121 | | if (take < 0) |
| | 7122 | | { |
| 0 | 7123 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0); |
| | 7124 | | } |
| | 7125 | | // Tracing |
| 1 | 7126 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 7127 | | string _invocationId = null; |
| 1 | 7128 | | if (_shouldTrace) |
| | 7129 | | { |
| 0 | 7130 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 7131 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 7132 | | tracingParameters.Add("appId", appId); |
| 0 | 7133 | | tracingParameters.Add("versionId", versionId); |
| 0 | 7134 | | tracingParameters.Add("entityId", entityId); |
| 0 | 7135 | | tracingParameters.Add("take", take); |
| 0 | 7136 | | tracingParameters.Add("enableNestedChildren", enableNestedChildren); |
| 0 | 7137 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 7138 | | ServiceClientTracing.Enter(_invocationId, this, "ListEntitySuggestions", tracingParameters); |
| | 7139 | | } |
| | 7140 | | // Construct URL |
| 1 | 7141 | | var _baseUrl = Client.BaseUri; |
| 1 | 7142 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent |
| 1 | 7143 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 7144 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 7145 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 7146 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 7147 | | List<string> _queryParameters = new List<string>(); |
| 1 | 7148 | | if (take != null) |
| | 7149 | | { |
| 1 | 7150 | | _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 7151 | | } |
| 1 | 7152 | | if (enableNestedChildren != null) |
| | 7153 | | { |
| 1 | 7154 | | _queryParameters.Add(string.Format("enableNestedChildren={0}", System.Uri.EscapeDataString(Rest.Serializ |
| | 7155 | | } |
| 1 | 7156 | | if (_queryParameters.Count > 0) |
| | 7157 | | { |
| 1 | 7158 | | _url += "?" + string.Join("&", _queryParameters); |
| | 7159 | | } |
| | 7160 | | // Create HTTP transport objects |
| 1 | 7161 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 7162 | | HttpResponseMessage _httpResponse = null; |
| 1 | 7163 | | _httpRequest.Method = new HttpMethod("GET"); |
| 1 | 7164 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 7165 | | // Set Headers |
| | 7166 | |
|
| | 7167 | |
|
| 1 | 7168 | | if (customHeaders != null) |
| | 7169 | | { |
| 0 | 7170 | | foreach(var _header in customHeaders) |
| | 7171 | | { |
| 0 | 7172 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 7173 | | { |
| 0 | 7174 | | _httpRequest.Headers.Remove(_header.Key); |
| | 7175 | | } |
| 0 | 7176 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 7177 | | } |
| | 7178 | | } |
| | 7179 | |
|
| | 7180 | | // Serialize Request |
| 1 | 7181 | | string _requestContent = null; |
| | 7182 | | // Set Credentials |
| 1 | 7183 | | if (Client.Credentials != null) |
| | 7184 | | { |
| 1 | 7185 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 7186 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 7187 | | } |
| | 7188 | | // Send Request |
| 1 | 7189 | | if (_shouldTrace) |
| | 7190 | | { |
| 0 | 7191 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 7192 | | } |
| 1 | 7193 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 7194 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 7195 | | if (_shouldTrace) |
| | 7196 | | { |
| 0 | 7197 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 7198 | | } |
| 1 | 7199 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 7200 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 7201 | | string _responseContent = null; |
| 1 | 7202 | | if ((int)_statusCode != 200) |
| | 7203 | | { |
| 0 | 7204 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 7205 | | try |
| | 7206 | | { |
| 0 | 7207 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 7208 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 7209 | | if (_errorBody != null) |
| | 7210 | | { |
| 0 | 7211 | | ex.Body = _errorBody; |
| | 7212 | | } |
| 0 | 7213 | | } |
| 0 | 7214 | | catch (JsonException) |
| | 7215 | | { |
| | 7216 | | // Ignore the exception |
| 0 | 7217 | | } |
| 0 | 7218 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 7219 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 7220 | | if (_shouldTrace) |
| | 7221 | | { |
| 0 | 7222 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 7223 | | } |
| 0 | 7224 | | _httpRequest.Dispose(); |
| 0 | 7225 | | if (_httpResponse != null) |
| | 7226 | | { |
| 0 | 7227 | | _httpResponse.Dispose(); |
| | 7228 | | } |
| 0 | 7229 | | throw ex; |
| | 7230 | | } |
| | 7231 | | // Create Result |
| 1 | 7232 | | var _result = new HttpOperationResponse<IList<EntitiesSuggestionExample>>(); |
| 1 | 7233 | | _result.Request = _httpRequest; |
| 1 | 7234 | | _result.Response = _httpResponse; |
| | 7235 | | // Deserialize Response |
| 1 | 7236 | | if ((int)_statusCode == 200) |
| | 7237 | | { |
| 1 | 7238 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 7239 | | try |
| | 7240 | | { |
| 1 | 7241 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntitiesSuggestionExample> |
| 1 | 7242 | | } |
| 0 | 7243 | | catch (JsonException ex) |
| | 7244 | | { |
| 0 | 7245 | | _httpRequest.Dispose(); |
| 0 | 7246 | | if (_httpResponse != null) |
| | 7247 | | { |
| 0 | 7248 | | _httpResponse.Dispose(); |
| | 7249 | | } |
| 0 | 7250 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 7251 | | } |
| | 7252 | | } |
| 1 | 7253 | | if (_shouldTrace) |
| | 7254 | | { |
| 0 | 7255 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 7256 | | } |
| 1 | 7257 | | return _result; |
| 1 | 7258 | | } |
| | 7259 | |
|
| | 7260 | | /// <summary> |
| | 7261 | | /// Adds a sublist to an existing list entity in a version of the application. |
| | 7262 | | /// </summary> |
| | 7263 | | /// <param name='appId'> |
| | 7264 | | /// The application ID. |
| | 7265 | | /// </param> |
| | 7266 | | /// <param name='versionId'> |
| | 7267 | | /// The version ID. |
| | 7268 | | /// </param> |
| | 7269 | | /// <param name='clEntityId'> |
| | 7270 | | /// The list entity extractor ID. |
| | 7271 | | /// </param> |
| | 7272 | | /// <param name='wordListCreateObject'> |
| | 7273 | | /// Words list. |
| | 7274 | | /// </param> |
| | 7275 | | /// <param name='customHeaders'> |
| | 7276 | | /// Headers that will be added to request. |
| | 7277 | | /// </param> |
| | 7278 | | /// <param name='cancellationToken'> |
| | 7279 | | /// The cancellation token. |
| | 7280 | | /// </param> |
| | 7281 | | /// <exception cref="ErrorResponseException"> |
| | 7282 | | /// Thrown when the operation returned an invalid status code |
| | 7283 | | /// </exception> |
| | 7284 | | /// <exception cref="SerializationException"> |
| | 7285 | | /// Thrown when unable to deserialize the response |
| | 7286 | | /// </exception> |
| | 7287 | | /// <exception cref="ValidationException"> |
| | 7288 | | /// Thrown when a required parameter is null |
| | 7289 | | /// </exception> |
| | 7290 | | /// <exception cref="System.ArgumentNullException"> |
| | 7291 | | /// Thrown when a required parameter is null |
| | 7292 | | /// </exception> |
| | 7293 | | /// <return> |
| | 7294 | | /// A response object containing the response body and response headers. |
| | 7295 | | /// </return> |
| | 7296 | | public async Task<HttpOperationResponse<long?>> AddSubListWithHttpMessagesAsync(System.Guid appId, string versio |
| | 7297 | | { |
| 1 | 7298 | | if (Client.Endpoint == null) |
| | 7299 | | { |
| 0 | 7300 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 7301 | | } |
| 1 | 7302 | | if (versionId == null) |
| | 7303 | | { |
| 0 | 7304 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 7305 | | } |
| 1 | 7306 | | if (wordListCreateObject == null) |
| | 7307 | | { |
| 0 | 7308 | | throw new ValidationException(ValidationRules.CannotBeNull, "wordListCreateObject"); |
| | 7309 | | } |
| | 7310 | | // Tracing |
| 1 | 7311 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 7312 | | string _invocationId = null; |
| 1 | 7313 | | if (_shouldTrace) |
| | 7314 | | { |
| 0 | 7315 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 7316 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 7317 | | tracingParameters.Add("appId", appId); |
| 0 | 7318 | | tracingParameters.Add("versionId", versionId); |
| 0 | 7319 | | tracingParameters.Add("clEntityId", clEntityId); |
| 0 | 7320 | | tracingParameters.Add("wordListCreateObject", wordListCreateObject); |
| 0 | 7321 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 7322 | | ServiceClientTracing.Enter(_invocationId, this, "AddSubList", tracingParameters); |
| | 7323 | | } |
| | 7324 | | // Construct URL |
| 1 | 7325 | | var _baseUrl = Client.BaseUri; |
| 1 | 7326 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{ |
| 1 | 7327 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 7328 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 7329 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 7330 | | _url = _url.Replace("{clEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serialize |
| | 7331 | | // Create HTTP transport objects |
| 1 | 7332 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 7333 | | HttpResponseMessage _httpResponse = null; |
| 1 | 7334 | | _httpRequest.Method = new HttpMethod("POST"); |
| 1 | 7335 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 7336 | | // Set Headers |
| | 7337 | |
|
| | 7338 | |
|
| 1 | 7339 | | if (customHeaders != null) |
| | 7340 | | { |
| 0 | 7341 | | foreach(var _header in customHeaders) |
| | 7342 | | { |
| 0 | 7343 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 7344 | | { |
| 0 | 7345 | | _httpRequest.Headers.Remove(_header.Key); |
| | 7346 | | } |
| 0 | 7347 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 7348 | | } |
| | 7349 | | } |
| | 7350 | |
|
| | 7351 | | // Serialize Request |
| 1 | 7352 | | string _requestContent = null; |
| 1 | 7353 | | if(wordListCreateObject != null) |
| | 7354 | | { |
| 1 | 7355 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(wordListCreateObject, Client.Serial |
| 1 | 7356 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 7357 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 7358 | | } |
| | 7359 | | // Set Credentials |
| 1 | 7360 | | if (Client.Credentials != null) |
| | 7361 | | { |
| 1 | 7362 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 7363 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 7364 | | } |
| | 7365 | | // Send Request |
| 1 | 7366 | | if (_shouldTrace) |
| | 7367 | | { |
| 0 | 7368 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 7369 | | } |
| 1 | 7370 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 7371 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 7372 | | if (_shouldTrace) |
| | 7373 | | { |
| 0 | 7374 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 7375 | | } |
| 1 | 7376 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 7377 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 7378 | | string _responseContent = null; |
| 1 | 7379 | | if ((int)_statusCode != 201) |
| | 7380 | | { |
| 0 | 7381 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 7382 | | try |
| | 7383 | | { |
| 0 | 7384 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 7385 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 7386 | | if (_errorBody != null) |
| | 7387 | | { |
| 0 | 7388 | | ex.Body = _errorBody; |
| | 7389 | | } |
| 0 | 7390 | | } |
| 0 | 7391 | | catch (JsonException) |
| | 7392 | | { |
| | 7393 | | // Ignore the exception |
| 0 | 7394 | | } |
| 0 | 7395 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 7396 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 7397 | | if (_shouldTrace) |
| | 7398 | | { |
| 0 | 7399 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 7400 | | } |
| 0 | 7401 | | _httpRequest.Dispose(); |
| 0 | 7402 | | if (_httpResponse != null) |
| | 7403 | | { |
| 0 | 7404 | | _httpResponse.Dispose(); |
| | 7405 | | } |
| 0 | 7406 | | throw ex; |
| | 7407 | | } |
| | 7408 | | // Create Result |
| 1 | 7409 | | var _result = new HttpOperationResponse<long?>(); |
| 1 | 7410 | | _result.Request = _httpRequest; |
| 1 | 7411 | | _result.Response = _httpResponse; |
| | 7412 | | // Deserialize Response |
| 1 | 7413 | | if ((int)_statusCode == 201) |
| | 7414 | | { |
| 1 | 7415 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 7416 | | try |
| | 7417 | | { |
| 1 | 7418 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<long?>(_responseContent, Client. |
| 1 | 7419 | | } |
| 0 | 7420 | | catch (JsonException ex) |
| | 7421 | | { |
| 0 | 7422 | | _httpRequest.Dispose(); |
| 0 | 7423 | | if (_httpResponse != null) |
| | 7424 | | { |
| 0 | 7425 | | _httpResponse.Dispose(); |
| | 7426 | | } |
| 0 | 7427 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 7428 | | } |
| | 7429 | | } |
| 1 | 7430 | | if (_shouldTrace) |
| | 7431 | | { |
| 0 | 7432 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 7433 | | } |
| 1 | 7434 | | return _result; |
| 1 | 7435 | | } |
| | 7436 | |
|
| | 7437 | | /// <summary> |
| | 7438 | | /// Adds a customizable prebuilt domain along with all of its intent and entity |
| | 7439 | | /// models in a version of the application. |
| | 7440 | | /// </summary> |
| | 7441 | | /// <param name='appId'> |
| | 7442 | | /// The application ID. |
| | 7443 | | /// </param> |
| | 7444 | | /// <param name='versionId'> |
| | 7445 | | /// The version ID. |
| | 7446 | | /// </param> |
| | 7447 | | /// <param name='prebuiltDomainObject'> |
| | 7448 | | /// A prebuilt domain create object containing the name of the domain. |
| | 7449 | | /// </param> |
| | 7450 | | /// <param name='customHeaders'> |
| | 7451 | | /// Headers that will be added to request. |
| | 7452 | | /// </param> |
| | 7453 | | /// <param name='cancellationToken'> |
| | 7454 | | /// The cancellation token. |
| | 7455 | | /// </param> |
| | 7456 | | /// <exception cref="ErrorResponseException"> |
| | 7457 | | /// Thrown when the operation returned an invalid status code |
| | 7458 | | /// </exception> |
| | 7459 | | /// <exception cref="SerializationException"> |
| | 7460 | | /// Thrown when unable to deserialize the response |
| | 7461 | | /// </exception> |
| | 7462 | | /// <exception cref="ValidationException"> |
| | 7463 | | /// Thrown when a required parameter is null |
| | 7464 | | /// </exception> |
| | 7465 | | /// <exception cref="System.ArgumentNullException"> |
| | 7466 | | /// Thrown when a required parameter is null |
| | 7467 | | /// </exception> |
| | 7468 | | /// <return> |
| | 7469 | | /// A response object containing the response body and response headers. |
| | 7470 | | /// </return> |
| | 7471 | | public async Task<HttpOperationResponse<IList<System.Guid?>>> AddCustomPrebuiltDomainWithHttpMessagesAsync(Syste |
| | 7472 | | { |
| 5 | 7473 | | if (Client.Endpoint == null) |
| | 7474 | | { |
| 0 | 7475 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 7476 | | } |
| 5 | 7477 | | if (versionId == null) |
| | 7478 | | { |
| 0 | 7479 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 7480 | | } |
| 5 | 7481 | | if (prebuiltDomainObject == null) |
| | 7482 | | { |
| 0 | 7483 | | throw new ValidationException(ValidationRules.CannotBeNull, "prebuiltDomainObject"); |
| | 7484 | | } |
| | 7485 | | // Tracing |
| 5 | 7486 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 5 | 7487 | | string _invocationId = null; |
| 5 | 7488 | | if (_shouldTrace) |
| | 7489 | | { |
| 0 | 7490 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 7491 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 7492 | | tracingParameters.Add("appId", appId); |
| 0 | 7493 | | tracingParameters.Add("versionId", versionId); |
| 0 | 7494 | | tracingParameters.Add("prebuiltDomainObject", prebuiltDomainObject); |
| 0 | 7495 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 7496 | | ServiceClientTracing.Enter(_invocationId, this, "AddCustomPrebuiltDomain", tracingParameters); |
| | 7497 | | } |
| | 7498 | | // Construct URL |
| 5 | 7499 | | var _baseUrl = Client.BaseUri; |
| 5 | 7500 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil |
| 5 | 7501 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 5 | 7502 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 5 | 7503 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| | 7504 | | // Create HTTP transport objects |
| 5 | 7505 | | var _httpRequest = new HttpRequestMessage(); |
| 5 | 7506 | | HttpResponseMessage _httpResponse = null; |
| 5 | 7507 | | _httpRequest.Method = new HttpMethod("POST"); |
| 5 | 7508 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 7509 | | // Set Headers |
| | 7510 | |
|
| | 7511 | |
|
| 5 | 7512 | | if (customHeaders != null) |
| | 7513 | | { |
| 0 | 7514 | | foreach(var _header in customHeaders) |
| | 7515 | | { |
| 0 | 7516 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 7517 | | { |
| 0 | 7518 | | _httpRequest.Headers.Remove(_header.Key); |
| | 7519 | | } |
| 0 | 7520 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 7521 | | } |
| | 7522 | | } |
| | 7523 | |
|
| | 7524 | | // Serialize Request |
| 5 | 7525 | | string _requestContent = null; |
| 5 | 7526 | | if(prebuiltDomainObject != null) |
| | 7527 | | { |
| 5 | 7528 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(prebuiltDomainObject, Client.Serial |
| 5 | 7529 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 5 | 7530 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 7531 | | } |
| | 7532 | | // Set Credentials |
| 5 | 7533 | | if (Client.Credentials != null) |
| | 7534 | | { |
| 5 | 7535 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 7536 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 7537 | | } |
| | 7538 | | // Send Request |
| 5 | 7539 | | if (_shouldTrace) |
| | 7540 | | { |
| 0 | 7541 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 7542 | | } |
| 5 | 7543 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 7544 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 5 | 7545 | | if (_shouldTrace) |
| | 7546 | | { |
| 0 | 7547 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 7548 | | } |
| 5 | 7549 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 5 | 7550 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 7551 | | string _responseContent = null; |
| 5 | 7552 | | if ((int)_statusCode != 201) |
| | 7553 | | { |
| 0 | 7554 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 7555 | | try |
| | 7556 | | { |
| 0 | 7557 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 7558 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 7559 | | if (_errorBody != null) |
| | 7560 | | { |
| 0 | 7561 | | ex.Body = _errorBody; |
| | 7562 | | } |
| 0 | 7563 | | } |
| 0 | 7564 | | catch (JsonException) |
| | 7565 | | { |
| | 7566 | | // Ignore the exception |
| 0 | 7567 | | } |
| 0 | 7568 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 7569 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 7570 | | if (_shouldTrace) |
| | 7571 | | { |
| 0 | 7572 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 7573 | | } |
| 0 | 7574 | | _httpRequest.Dispose(); |
| 0 | 7575 | | if (_httpResponse != null) |
| | 7576 | | { |
| 0 | 7577 | | _httpResponse.Dispose(); |
| | 7578 | | } |
| 0 | 7579 | | throw ex; |
| | 7580 | | } |
| | 7581 | | // Create Result |
| 5 | 7582 | | var _result = new HttpOperationResponse<IList<System.Guid?>>(); |
| 5 | 7583 | | _result.Request = _httpRequest; |
| 5 | 7584 | | _result.Response = _httpResponse; |
| | 7585 | | // Deserialize Response |
| 5 | 7586 | | if ((int)_statusCode == 201) |
| | 7587 | | { |
| 5 | 7588 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 7589 | | try |
| | 7590 | | { |
| 5 | 7591 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<System.Guid?>>(_responseCo |
| 5 | 7592 | | } |
| 0 | 7593 | | catch (JsonException ex) |
| | 7594 | | { |
| 0 | 7595 | | _httpRequest.Dispose(); |
| 0 | 7596 | | if (_httpResponse != null) |
| | 7597 | | { |
| 0 | 7598 | | _httpResponse.Dispose(); |
| | 7599 | | } |
| 0 | 7600 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 7601 | | } |
| | 7602 | | } |
| 5 | 7603 | | if (_shouldTrace) |
| | 7604 | | { |
| 0 | 7605 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 7606 | | } |
| 5 | 7607 | | return _result; |
| 5 | 7608 | | } |
| | 7609 | |
|
| | 7610 | | /// <summary> |
| | 7611 | | /// Adds a customizable prebuilt intent model to a version of the application. |
| | 7612 | | /// </summary> |
| | 7613 | | /// <param name='appId'> |
| | 7614 | | /// The application ID. |
| | 7615 | | /// </param> |
| | 7616 | | /// <param name='versionId'> |
| | 7617 | | /// The version ID. |
| | 7618 | | /// </param> |
| | 7619 | | /// <param name='prebuiltDomainModelCreateObject'> |
| | 7620 | | /// A model object containing the name of the customizable prebuilt intent and |
| | 7621 | | /// the name of the domain to which this model belongs. |
| | 7622 | | /// </param> |
| | 7623 | | /// <param name='customHeaders'> |
| | 7624 | | /// Headers that will be added to request. |
| | 7625 | | /// </param> |
| | 7626 | | /// <param name='cancellationToken'> |
| | 7627 | | /// The cancellation token. |
| | 7628 | | /// </param> |
| | 7629 | | /// <exception cref="ErrorResponseException"> |
| | 7630 | | /// Thrown when the operation returned an invalid status code |
| | 7631 | | /// </exception> |
| | 7632 | | /// <exception cref="SerializationException"> |
| | 7633 | | /// Thrown when unable to deserialize the response |
| | 7634 | | /// </exception> |
| | 7635 | | /// <exception cref="ValidationException"> |
| | 7636 | | /// Thrown when a required parameter is null |
| | 7637 | | /// </exception> |
| | 7638 | | /// <exception cref="System.ArgumentNullException"> |
| | 7639 | | /// Thrown when a required parameter is null |
| | 7640 | | /// </exception> |
| | 7641 | | /// <return> |
| | 7642 | | /// A response object containing the response body and response headers. |
| | 7643 | | /// </return> |
| | 7644 | | public async Task<HttpOperationResponse<System.Guid>> AddCustomPrebuiltIntentWithHttpMessagesAsync(System.Guid a |
| | 7645 | | { |
| 1 | 7646 | | if (Client.Endpoint == null) |
| | 7647 | | { |
| 0 | 7648 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 7649 | | } |
| 1 | 7650 | | if (versionId == null) |
| | 7651 | | { |
| 0 | 7652 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 7653 | | } |
| 1 | 7654 | | if (prebuiltDomainModelCreateObject == null) |
| | 7655 | | { |
| 0 | 7656 | | throw new ValidationException(ValidationRules.CannotBeNull, "prebuiltDomainModelCreateObject"); |
| | 7657 | | } |
| | 7658 | | // Tracing |
| 1 | 7659 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 7660 | | string _invocationId = null; |
| 1 | 7661 | | if (_shouldTrace) |
| | 7662 | | { |
| 0 | 7663 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 7664 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 7665 | | tracingParameters.Add("appId", appId); |
| 0 | 7666 | | tracingParameters.Add("versionId", versionId); |
| 0 | 7667 | | tracingParameters.Add("prebuiltDomainModelCreateObject", prebuiltDomainModelCreateObject); |
| 0 | 7668 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 7669 | | ServiceClientTracing.Enter(_invocationId, this, "AddCustomPrebuiltIntent", tracingParameters); |
| | 7670 | | } |
| | 7671 | | // Construct URL |
| 1 | 7672 | | var _baseUrl = Client.BaseUri; |
| 1 | 7673 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil |
| 1 | 7674 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 7675 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 7676 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| | 7677 | | // Create HTTP transport objects |
| 1 | 7678 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 7679 | | HttpResponseMessage _httpResponse = null; |
| 1 | 7680 | | _httpRequest.Method = new HttpMethod("POST"); |
| 1 | 7681 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 7682 | | // Set Headers |
| | 7683 | |
|
| | 7684 | |
|
| 1 | 7685 | | if (customHeaders != null) |
| | 7686 | | { |
| 0 | 7687 | | foreach(var _header in customHeaders) |
| | 7688 | | { |
| 0 | 7689 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 7690 | | { |
| 0 | 7691 | | _httpRequest.Headers.Remove(_header.Key); |
| | 7692 | | } |
| 0 | 7693 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 7694 | | } |
| | 7695 | | } |
| | 7696 | |
|
| | 7697 | | // Serialize Request |
| 1 | 7698 | | string _requestContent = null; |
| 1 | 7699 | | if(prebuiltDomainModelCreateObject != null) |
| | 7700 | | { |
| 1 | 7701 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(prebuiltDomainModelCreateObject, Cl |
| 1 | 7702 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 7703 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 7704 | | } |
| | 7705 | | // Set Credentials |
| 1 | 7706 | | if (Client.Credentials != null) |
| | 7707 | | { |
| 1 | 7708 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 7709 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 7710 | | } |
| | 7711 | | // Send Request |
| 1 | 7712 | | if (_shouldTrace) |
| | 7713 | | { |
| 0 | 7714 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 7715 | | } |
| 1 | 7716 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 7717 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 7718 | | if (_shouldTrace) |
| | 7719 | | { |
| 0 | 7720 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 7721 | | } |
| 1 | 7722 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 7723 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 7724 | | string _responseContent = null; |
| 1 | 7725 | | if ((int)_statusCode != 201) |
| | 7726 | | { |
| 0 | 7727 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 7728 | | try |
| | 7729 | | { |
| 0 | 7730 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 7731 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 7732 | | if (_errorBody != null) |
| | 7733 | | { |
| 0 | 7734 | | ex.Body = _errorBody; |
| | 7735 | | } |
| 0 | 7736 | | } |
| 0 | 7737 | | catch (JsonException) |
| | 7738 | | { |
| | 7739 | | // Ignore the exception |
| 0 | 7740 | | } |
| 0 | 7741 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 7742 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 7743 | | if (_shouldTrace) |
| | 7744 | | { |
| 0 | 7745 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 7746 | | } |
| 0 | 7747 | | _httpRequest.Dispose(); |
| 0 | 7748 | | if (_httpResponse != null) |
| | 7749 | | { |
| 0 | 7750 | | _httpResponse.Dispose(); |
| | 7751 | | } |
| 0 | 7752 | | throw ex; |
| | 7753 | | } |
| | 7754 | | // Create Result |
| 1 | 7755 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 1 | 7756 | | _result.Request = _httpRequest; |
| 1 | 7757 | | _result.Response = _httpResponse; |
| | 7758 | | // Deserialize Response |
| 1 | 7759 | | if ((int)_statusCode == 201) |
| | 7760 | | { |
| 1 | 7761 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 7762 | | try |
| | 7763 | | { |
| 1 | 7764 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 1 | 7765 | | } |
| 0 | 7766 | | catch (JsonException ex) |
| | 7767 | | { |
| 0 | 7768 | | _httpRequest.Dispose(); |
| 0 | 7769 | | if (_httpResponse != null) |
| | 7770 | | { |
| 0 | 7771 | | _httpResponse.Dispose(); |
| | 7772 | | } |
| 0 | 7773 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 7774 | | } |
| | 7775 | | } |
| 1 | 7776 | | if (_shouldTrace) |
| | 7777 | | { |
| 0 | 7778 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 7779 | | } |
| 1 | 7780 | | return _result; |
| 1 | 7781 | | } |
| | 7782 | |
|
| | 7783 | | /// <summary> |
| | 7784 | | /// Gets information about customizable prebuilt intents added to a version of |
| | 7785 | | /// the application. |
| | 7786 | | /// </summary> |
| | 7787 | | /// <param name='appId'> |
| | 7788 | | /// The application ID. |
| | 7789 | | /// </param> |
| | 7790 | | /// <param name='versionId'> |
| | 7791 | | /// The version ID. |
| | 7792 | | /// </param> |
| | 7793 | | /// <param name='customHeaders'> |
| | 7794 | | /// Headers that will be added to request. |
| | 7795 | | /// </param> |
| | 7796 | | /// <param name='cancellationToken'> |
| | 7797 | | /// The cancellation token. |
| | 7798 | | /// </param> |
| | 7799 | | /// <exception cref="ErrorResponseException"> |
| | 7800 | | /// Thrown when the operation returned an invalid status code |
| | 7801 | | /// </exception> |
| | 7802 | | /// <exception cref="SerializationException"> |
| | 7803 | | /// Thrown when unable to deserialize the response |
| | 7804 | | /// </exception> |
| | 7805 | | /// <exception cref="ValidationException"> |
| | 7806 | | /// Thrown when a required parameter is null |
| | 7807 | | /// </exception> |
| | 7808 | | /// <exception cref="System.ArgumentNullException"> |
| | 7809 | | /// Thrown when a required parameter is null |
| | 7810 | | /// </exception> |
| | 7811 | | /// <return> |
| | 7812 | | /// A response object containing the response body and response headers. |
| | 7813 | | /// </return> |
| | 7814 | | public async Task<HttpOperationResponse<IList<IntentClassifier>>> ListCustomPrebuiltIntentsWithHttpMessagesAsync |
| | 7815 | | { |
| 2 | 7816 | | if (Client.Endpoint == null) |
| | 7817 | | { |
| 0 | 7818 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 7819 | | } |
| 2 | 7820 | | if (versionId == null) |
| | 7821 | | { |
| 0 | 7822 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 7823 | | } |
| | 7824 | | // Tracing |
| 2 | 7825 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 7826 | | string _invocationId = null; |
| 2 | 7827 | | if (_shouldTrace) |
| | 7828 | | { |
| 0 | 7829 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 7830 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 7831 | | tracingParameters.Add("appId", appId); |
| 0 | 7832 | | tracingParameters.Add("versionId", versionId); |
| 0 | 7833 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 7834 | | ServiceClientTracing.Enter(_invocationId, this, "ListCustomPrebuiltIntents", tracingParameters); |
| | 7835 | | } |
| | 7836 | | // Construct URL |
| 2 | 7837 | | var _baseUrl = Client.BaseUri; |
| 2 | 7838 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil |
| 2 | 7839 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 7840 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 7841 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| | 7842 | | // Create HTTP transport objects |
| 2 | 7843 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 7844 | | HttpResponseMessage _httpResponse = null; |
| 2 | 7845 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 7846 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 7847 | | // Set Headers |
| | 7848 | |
|
| | 7849 | |
|
| 2 | 7850 | | if (customHeaders != null) |
| | 7851 | | { |
| 0 | 7852 | | foreach(var _header in customHeaders) |
| | 7853 | | { |
| 0 | 7854 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 7855 | | { |
| 0 | 7856 | | _httpRequest.Headers.Remove(_header.Key); |
| | 7857 | | } |
| 0 | 7858 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 7859 | | } |
| | 7860 | | } |
| | 7861 | |
|
| | 7862 | | // Serialize Request |
| 2 | 7863 | | string _requestContent = null; |
| | 7864 | | // Set Credentials |
| 2 | 7865 | | if (Client.Credentials != null) |
| | 7866 | | { |
| 2 | 7867 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 7868 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 7869 | | } |
| | 7870 | | // Send Request |
| 2 | 7871 | | if (_shouldTrace) |
| | 7872 | | { |
| 0 | 7873 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 7874 | | } |
| 2 | 7875 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 7876 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 7877 | | if (_shouldTrace) |
| | 7878 | | { |
| 0 | 7879 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 7880 | | } |
| 2 | 7881 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 7882 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 7883 | | string _responseContent = null; |
| 2 | 7884 | | if ((int)_statusCode != 200) |
| | 7885 | | { |
| 0 | 7886 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 7887 | | try |
| | 7888 | | { |
| 0 | 7889 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 7890 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 7891 | | if (_errorBody != null) |
| | 7892 | | { |
| 0 | 7893 | | ex.Body = _errorBody; |
| | 7894 | | } |
| 0 | 7895 | | } |
| 0 | 7896 | | catch (JsonException) |
| | 7897 | | { |
| | 7898 | | // Ignore the exception |
| 0 | 7899 | | } |
| 0 | 7900 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 7901 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 7902 | | if (_shouldTrace) |
| | 7903 | | { |
| 0 | 7904 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 7905 | | } |
| 0 | 7906 | | _httpRequest.Dispose(); |
| 0 | 7907 | | if (_httpResponse != null) |
| | 7908 | | { |
| 0 | 7909 | | _httpResponse.Dispose(); |
| | 7910 | | } |
| 0 | 7911 | | throw ex; |
| | 7912 | | } |
| | 7913 | | // Create Result |
| 2 | 7914 | | var _result = new HttpOperationResponse<IList<IntentClassifier>>(); |
| 2 | 7915 | | _result.Request = _httpRequest; |
| 2 | 7916 | | _result.Response = _httpResponse; |
| | 7917 | | // Deserialize Response |
| 2 | 7918 | | if ((int)_statusCode == 200) |
| | 7919 | | { |
| 2 | 7920 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 7921 | | try |
| | 7922 | | { |
| 2 | 7923 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<IntentClassifier>>(_respon |
| 2 | 7924 | | } |
| 0 | 7925 | | catch (JsonException ex) |
| | 7926 | | { |
| 0 | 7927 | | _httpRequest.Dispose(); |
| 0 | 7928 | | if (_httpResponse != null) |
| | 7929 | | { |
| 0 | 7930 | | _httpResponse.Dispose(); |
| | 7931 | | } |
| 0 | 7932 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 7933 | | } |
| | 7934 | | } |
| 2 | 7935 | | if (_shouldTrace) |
| | 7936 | | { |
| 0 | 7937 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 7938 | | } |
| 2 | 7939 | | return _result; |
| 2 | 7940 | | } |
| | 7941 | |
|
| | 7942 | | /// <summary> |
| | 7943 | | /// Adds a prebuilt entity model to a version of the application. |
| | 7944 | | /// </summary> |
| | 7945 | | /// <param name='appId'> |
| | 7946 | | /// The application ID. |
| | 7947 | | /// </param> |
| | 7948 | | /// <param name='versionId'> |
| | 7949 | | /// The version ID. |
| | 7950 | | /// </param> |
| | 7951 | | /// <param name='prebuiltDomainModelCreateObject'> |
| | 7952 | | /// A model object containing the name of the prebuilt entity and the name of |
| | 7953 | | /// the domain to which this model belongs. |
| | 7954 | | /// </param> |
| | 7955 | | /// <param name='customHeaders'> |
| | 7956 | | /// Headers that will be added to request. |
| | 7957 | | /// </param> |
| | 7958 | | /// <param name='cancellationToken'> |
| | 7959 | | /// The cancellation token. |
| | 7960 | | /// </param> |
| | 7961 | | /// <exception cref="ErrorResponseException"> |
| | 7962 | | /// Thrown when the operation returned an invalid status code |
| | 7963 | | /// </exception> |
| | 7964 | | /// <exception cref="SerializationException"> |
| | 7965 | | /// Thrown when unable to deserialize the response |
| | 7966 | | /// </exception> |
| | 7967 | | /// <exception cref="ValidationException"> |
| | 7968 | | /// Thrown when a required parameter is null |
| | 7969 | | /// </exception> |
| | 7970 | | /// <exception cref="System.ArgumentNullException"> |
| | 7971 | | /// Thrown when a required parameter is null |
| | 7972 | | /// </exception> |
| | 7973 | | /// <return> |
| | 7974 | | /// A response object containing the response body and response headers. |
| | 7975 | | /// </return> |
| | 7976 | | public async Task<HttpOperationResponse<System.Guid>> AddCustomPrebuiltEntityWithHttpMessagesAsync(System.Guid a |
| | 7977 | | { |
| 6 | 7978 | | if (Client.Endpoint == null) |
| | 7979 | | { |
| 0 | 7980 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 7981 | | } |
| 6 | 7982 | | if (versionId == null) |
| | 7983 | | { |
| 0 | 7984 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 7985 | | } |
| 6 | 7986 | | if (prebuiltDomainModelCreateObject == null) |
| | 7987 | | { |
| 0 | 7988 | | throw new ValidationException(ValidationRules.CannotBeNull, "prebuiltDomainModelCreateObject"); |
| | 7989 | | } |
| | 7990 | | // Tracing |
| 6 | 7991 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 6 | 7992 | | string _invocationId = null; |
| 6 | 7993 | | if (_shouldTrace) |
| | 7994 | | { |
| 0 | 7995 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 7996 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 7997 | | tracingParameters.Add("appId", appId); |
| 0 | 7998 | | tracingParameters.Add("versionId", versionId); |
| 0 | 7999 | | tracingParameters.Add("prebuiltDomainModelCreateObject", prebuiltDomainModelCreateObject); |
| 0 | 8000 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 8001 | | ServiceClientTracing.Enter(_invocationId, this, "AddCustomPrebuiltEntity", tracingParameters); |
| | 8002 | | } |
| | 8003 | | // Construct URL |
| 6 | 8004 | | var _baseUrl = Client.BaseUri; |
| 6 | 8005 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil |
| 6 | 8006 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 6 | 8007 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 6 | 8008 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| | 8009 | | // Create HTTP transport objects |
| 6 | 8010 | | var _httpRequest = new HttpRequestMessage(); |
| 6 | 8011 | | HttpResponseMessage _httpResponse = null; |
| 6 | 8012 | | _httpRequest.Method = new HttpMethod("POST"); |
| 6 | 8013 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 8014 | | // Set Headers |
| | 8015 | |
|
| | 8016 | |
|
| 6 | 8017 | | if (customHeaders != null) |
| | 8018 | | { |
| 0 | 8019 | | foreach(var _header in customHeaders) |
| | 8020 | | { |
| 0 | 8021 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 8022 | | { |
| 0 | 8023 | | _httpRequest.Headers.Remove(_header.Key); |
| | 8024 | | } |
| 0 | 8025 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 8026 | | } |
| | 8027 | | } |
| | 8028 | |
|
| | 8029 | | // Serialize Request |
| 6 | 8030 | | string _requestContent = null; |
| 6 | 8031 | | if(prebuiltDomainModelCreateObject != null) |
| | 8032 | | { |
| 6 | 8033 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(prebuiltDomainModelCreateObject, Cl |
| 6 | 8034 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 6 | 8035 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 8036 | | } |
| | 8037 | | // Set Credentials |
| 6 | 8038 | | if (Client.Credentials != null) |
| | 8039 | | { |
| 6 | 8040 | | cancellationToken.ThrowIfCancellationRequested(); |
| 6 | 8041 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 8042 | | } |
| | 8043 | | // Send Request |
| 6 | 8044 | | if (_shouldTrace) |
| | 8045 | | { |
| 0 | 8046 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 8047 | | } |
| 6 | 8048 | | cancellationToken.ThrowIfCancellationRequested(); |
| 6 | 8049 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 6 | 8050 | | if (_shouldTrace) |
| | 8051 | | { |
| 0 | 8052 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 8053 | | } |
| 6 | 8054 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 6 | 8055 | | cancellationToken.ThrowIfCancellationRequested(); |
| 6 | 8056 | | string _responseContent = null; |
| 6 | 8057 | | if ((int)_statusCode != 201) |
| | 8058 | | { |
| 0 | 8059 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 8060 | | try |
| | 8061 | | { |
| 0 | 8062 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 8063 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 8064 | | if (_errorBody != null) |
| | 8065 | | { |
| 0 | 8066 | | ex.Body = _errorBody; |
| | 8067 | | } |
| 0 | 8068 | | } |
| 0 | 8069 | | catch (JsonException) |
| | 8070 | | { |
| | 8071 | | // Ignore the exception |
| 0 | 8072 | | } |
| 0 | 8073 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 8074 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 8075 | | if (_shouldTrace) |
| | 8076 | | { |
| 0 | 8077 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 8078 | | } |
| 0 | 8079 | | _httpRequest.Dispose(); |
| 0 | 8080 | | if (_httpResponse != null) |
| | 8081 | | { |
| 0 | 8082 | | _httpResponse.Dispose(); |
| | 8083 | | } |
| 0 | 8084 | | throw ex; |
| | 8085 | | } |
| | 8086 | | // Create Result |
| 6 | 8087 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 6 | 8088 | | _result.Request = _httpRequest; |
| 6 | 8089 | | _result.Response = _httpResponse; |
| | 8090 | | // Deserialize Response |
| 6 | 8091 | | if ((int)_statusCode == 201) |
| | 8092 | | { |
| 6 | 8093 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 8094 | | try |
| | 8095 | | { |
| 6 | 8096 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 6 | 8097 | | } |
| 0 | 8098 | | catch (JsonException ex) |
| | 8099 | | { |
| 0 | 8100 | | _httpRequest.Dispose(); |
| 0 | 8101 | | if (_httpResponse != null) |
| | 8102 | | { |
| 0 | 8103 | | _httpResponse.Dispose(); |
| | 8104 | | } |
| 0 | 8105 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 8106 | | } |
| | 8107 | | } |
| 6 | 8108 | | if (_shouldTrace) |
| | 8109 | | { |
| 0 | 8110 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 8111 | | } |
| 6 | 8112 | | return _result; |
| 6 | 8113 | | } |
| | 8114 | |
|
| | 8115 | | /// <summary> |
| | 8116 | | /// Gets all prebuilt entities used in a version of the application. |
| | 8117 | | /// </summary> |
| | 8118 | | /// <param name='appId'> |
| | 8119 | | /// The application ID. |
| | 8120 | | /// </param> |
| | 8121 | | /// <param name='versionId'> |
| | 8122 | | /// The version ID. |
| | 8123 | | /// </param> |
| | 8124 | | /// <param name='customHeaders'> |
| | 8125 | | /// Headers that will be added to request. |
| | 8126 | | /// </param> |
| | 8127 | | /// <param name='cancellationToken'> |
| | 8128 | | /// The cancellation token. |
| | 8129 | | /// </param> |
| | 8130 | | /// <exception cref="ErrorResponseException"> |
| | 8131 | | /// Thrown when the operation returned an invalid status code |
| | 8132 | | /// </exception> |
| | 8133 | | /// <exception cref="SerializationException"> |
| | 8134 | | /// Thrown when unable to deserialize the response |
| | 8135 | | /// </exception> |
| | 8136 | | /// <exception cref="ValidationException"> |
| | 8137 | | /// Thrown when a required parameter is null |
| | 8138 | | /// </exception> |
| | 8139 | | /// <exception cref="System.ArgumentNullException"> |
| | 8140 | | /// Thrown when a required parameter is null |
| | 8141 | | /// </exception> |
| | 8142 | | /// <return> |
| | 8143 | | /// A response object containing the response body and response headers. |
| | 8144 | | /// </return> |
| | 8145 | | public async Task<HttpOperationResponse<IList<EntityExtractor>>> ListCustomPrebuiltEntitiesWithHttpMessagesAsync |
| | 8146 | | { |
| 2 | 8147 | | if (Client.Endpoint == null) |
| | 8148 | | { |
| 0 | 8149 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 8150 | | } |
| 2 | 8151 | | if (versionId == null) |
| | 8152 | | { |
| 0 | 8153 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 8154 | | } |
| | 8155 | | // Tracing |
| 2 | 8156 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 8157 | | string _invocationId = null; |
| 2 | 8158 | | if (_shouldTrace) |
| | 8159 | | { |
| 0 | 8160 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 8161 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 8162 | | tracingParameters.Add("appId", appId); |
| 0 | 8163 | | tracingParameters.Add("versionId", versionId); |
| 0 | 8164 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 8165 | | ServiceClientTracing.Enter(_invocationId, this, "ListCustomPrebuiltEntities", tracingParameters); |
| | 8166 | | } |
| | 8167 | | // Construct URL |
| 2 | 8168 | | var _baseUrl = Client.BaseUri; |
| 2 | 8169 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil |
| 2 | 8170 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 8171 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 8172 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| | 8173 | | // Create HTTP transport objects |
| 2 | 8174 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 8175 | | HttpResponseMessage _httpResponse = null; |
| 2 | 8176 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 8177 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 8178 | | // Set Headers |
| | 8179 | |
|
| | 8180 | |
|
| 2 | 8181 | | if (customHeaders != null) |
| | 8182 | | { |
| 0 | 8183 | | foreach(var _header in customHeaders) |
| | 8184 | | { |
| 0 | 8185 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 8186 | | { |
| 0 | 8187 | | _httpRequest.Headers.Remove(_header.Key); |
| | 8188 | | } |
| 0 | 8189 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 8190 | | } |
| | 8191 | | } |
| | 8192 | |
|
| | 8193 | | // Serialize Request |
| 2 | 8194 | | string _requestContent = null; |
| | 8195 | | // Set Credentials |
| 2 | 8196 | | if (Client.Credentials != null) |
| | 8197 | | { |
| 2 | 8198 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 8199 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 8200 | | } |
| | 8201 | | // Send Request |
| 2 | 8202 | | if (_shouldTrace) |
| | 8203 | | { |
| 0 | 8204 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 8205 | | } |
| 2 | 8206 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 8207 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 8208 | | if (_shouldTrace) |
| | 8209 | | { |
| 0 | 8210 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 8211 | | } |
| 2 | 8212 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 8213 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 8214 | | string _responseContent = null; |
| 2 | 8215 | | if ((int)_statusCode != 200) |
| | 8216 | | { |
| 0 | 8217 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 8218 | | try |
| | 8219 | | { |
| 0 | 8220 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 8221 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 8222 | | if (_errorBody != null) |
| | 8223 | | { |
| 0 | 8224 | | ex.Body = _errorBody; |
| | 8225 | | } |
| 0 | 8226 | | } |
| 0 | 8227 | | catch (JsonException) |
| | 8228 | | { |
| | 8229 | | // Ignore the exception |
| 0 | 8230 | | } |
| 0 | 8231 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 8232 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 8233 | | if (_shouldTrace) |
| | 8234 | | { |
| 0 | 8235 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 8236 | | } |
| 0 | 8237 | | _httpRequest.Dispose(); |
| 0 | 8238 | | if (_httpResponse != null) |
| | 8239 | | { |
| 0 | 8240 | | _httpResponse.Dispose(); |
| | 8241 | | } |
| 0 | 8242 | | throw ex; |
| | 8243 | | } |
| | 8244 | | // Create Result |
| 2 | 8245 | | var _result = new HttpOperationResponse<IList<EntityExtractor>>(); |
| 2 | 8246 | | _result.Request = _httpRequest; |
| 2 | 8247 | | _result.Response = _httpResponse; |
| | 8248 | | // Deserialize Response |
| 2 | 8249 | | if ((int)_statusCode == 200) |
| | 8250 | | { |
| 2 | 8251 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 8252 | | try |
| | 8253 | | { |
| 2 | 8254 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityExtractor>>(_respons |
| 2 | 8255 | | } |
| 0 | 8256 | | catch (JsonException ex) |
| | 8257 | | { |
| 0 | 8258 | | _httpRequest.Dispose(); |
| 0 | 8259 | | if (_httpResponse != null) |
| | 8260 | | { |
| 0 | 8261 | | _httpResponse.Dispose(); |
| | 8262 | | } |
| 0 | 8263 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 8264 | | } |
| | 8265 | | } |
| 2 | 8266 | | if (_shouldTrace) |
| | 8267 | | { |
| 0 | 8268 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 8269 | | } |
| 2 | 8270 | | return _result; |
| 2 | 8271 | | } |
| | 8272 | |
|
| | 8273 | | /// <summary> |
| | 8274 | | /// Gets all prebuilt intent and entity model information used in a version of |
| | 8275 | | /// this application. |
| | 8276 | | /// </summary> |
| | 8277 | | /// <param name='appId'> |
| | 8278 | | /// The application ID. |
| | 8279 | | /// </param> |
| | 8280 | | /// <param name='versionId'> |
| | 8281 | | /// The version ID. |
| | 8282 | | /// </param> |
| | 8283 | | /// <param name='customHeaders'> |
| | 8284 | | /// Headers that will be added to request. |
| | 8285 | | /// </param> |
| | 8286 | | /// <param name='cancellationToken'> |
| | 8287 | | /// The cancellation token. |
| | 8288 | | /// </param> |
| | 8289 | | /// <exception cref="ErrorResponseException"> |
| | 8290 | | /// Thrown when the operation returned an invalid status code |
| | 8291 | | /// </exception> |
| | 8292 | | /// <exception cref="SerializationException"> |
| | 8293 | | /// Thrown when unable to deserialize the response |
| | 8294 | | /// </exception> |
| | 8295 | | /// <exception cref="ValidationException"> |
| | 8296 | | /// Thrown when a required parameter is null |
| | 8297 | | /// </exception> |
| | 8298 | | /// <exception cref="System.ArgumentNullException"> |
| | 8299 | | /// Thrown when a required parameter is null |
| | 8300 | | /// </exception> |
| | 8301 | | /// <return> |
| | 8302 | | /// A response object containing the response body and response headers. |
| | 8303 | | /// </return> |
| | 8304 | | public async Task<HttpOperationResponse<IList<CustomPrebuiltModel>>> ListCustomPrebuiltModelsWithHttpMessagesAsy |
| | 8305 | | { |
| 4 | 8306 | | if (Client.Endpoint == null) |
| | 8307 | | { |
| 0 | 8308 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 8309 | | } |
| 4 | 8310 | | if (versionId == null) |
| | 8311 | | { |
| 0 | 8312 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 8313 | | } |
| | 8314 | | // Tracing |
| 4 | 8315 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 4 | 8316 | | string _invocationId = null; |
| 4 | 8317 | | if (_shouldTrace) |
| | 8318 | | { |
| 0 | 8319 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 8320 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 8321 | | tracingParameters.Add("appId", appId); |
| 0 | 8322 | | tracingParameters.Add("versionId", versionId); |
| 0 | 8323 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 8324 | | ServiceClientTracing.Enter(_invocationId, this, "ListCustomPrebuiltModels", tracingParameters); |
| | 8325 | | } |
| | 8326 | | // Construct URL |
| 4 | 8327 | | var _baseUrl = Client.BaseUri; |
| 4 | 8328 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil |
| 4 | 8329 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 4 | 8330 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 4 | 8331 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| | 8332 | | // Create HTTP transport objects |
| 4 | 8333 | | var _httpRequest = new HttpRequestMessage(); |
| 4 | 8334 | | HttpResponseMessage _httpResponse = null; |
| 4 | 8335 | | _httpRequest.Method = new HttpMethod("GET"); |
| 4 | 8336 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 8337 | | // Set Headers |
| | 8338 | |
|
| | 8339 | |
|
| 4 | 8340 | | if (customHeaders != null) |
| | 8341 | | { |
| 0 | 8342 | | foreach(var _header in customHeaders) |
| | 8343 | | { |
| 0 | 8344 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 8345 | | { |
| 0 | 8346 | | _httpRequest.Headers.Remove(_header.Key); |
| | 8347 | | } |
| 0 | 8348 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 8349 | | } |
| | 8350 | | } |
| | 8351 | |
|
| | 8352 | | // Serialize Request |
| 4 | 8353 | | string _requestContent = null; |
| | 8354 | | // Set Credentials |
| 4 | 8355 | | if (Client.Credentials != null) |
| | 8356 | | { |
| 4 | 8357 | | cancellationToken.ThrowIfCancellationRequested(); |
| 4 | 8358 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 8359 | | } |
| | 8360 | | // Send Request |
| 4 | 8361 | | if (_shouldTrace) |
| | 8362 | | { |
| 0 | 8363 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 8364 | | } |
| 4 | 8365 | | cancellationToken.ThrowIfCancellationRequested(); |
| 4 | 8366 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 4 | 8367 | | if (_shouldTrace) |
| | 8368 | | { |
| 0 | 8369 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 8370 | | } |
| 4 | 8371 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 4 | 8372 | | cancellationToken.ThrowIfCancellationRequested(); |
| 4 | 8373 | | string _responseContent = null; |
| 4 | 8374 | | if ((int)_statusCode != 200) |
| | 8375 | | { |
| 0 | 8376 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 8377 | | try |
| | 8378 | | { |
| 0 | 8379 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 8380 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 8381 | | if (_errorBody != null) |
| | 8382 | | { |
| 0 | 8383 | | ex.Body = _errorBody; |
| | 8384 | | } |
| 0 | 8385 | | } |
| 0 | 8386 | | catch (JsonException) |
| | 8387 | | { |
| | 8388 | | // Ignore the exception |
| 0 | 8389 | | } |
| 0 | 8390 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 8391 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 8392 | | if (_shouldTrace) |
| | 8393 | | { |
| 0 | 8394 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 8395 | | } |
| 0 | 8396 | | _httpRequest.Dispose(); |
| 0 | 8397 | | if (_httpResponse != null) |
| | 8398 | | { |
| 0 | 8399 | | _httpResponse.Dispose(); |
| | 8400 | | } |
| 0 | 8401 | | throw ex; |
| | 8402 | | } |
| | 8403 | | // Create Result |
| 4 | 8404 | | var _result = new HttpOperationResponse<IList<CustomPrebuiltModel>>(); |
| 4 | 8405 | | _result.Request = _httpRequest; |
| 4 | 8406 | | _result.Response = _httpResponse; |
| | 8407 | | // Deserialize Response |
| 4 | 8408 | | if ((int)_statusCode == 200) |
| | 8409 | | { |
| 4 | 8410 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 8411 | | try |
| | 8412 | | { |
| 4 | 8413 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<CustomPrebuiltModel>>(_res |
| 4 | 8414 | | } |
| 0 | 8415 | | catch (JsonException ex) |
| | 8416 | | { |
| 0 | 8417 | | _httpRequest.Dispose(); |
| 0 | 8418 | | if (_httpResponse != null) |
| | 8419 | | { |
| 0 | 8420 | | _httpResponse.Dispose(); |
| | 8421 | | } |
| 0 | 8422 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 8423 | | } |
| | 8424 | | } |
| 4 | 8425 | | if (_shouldTrace) |
| | 8426 | | { |
| 0 | 8427 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 8428 | | } |
| 4 | 8429 | | return _result; |
| 4 | 8430 | | } |
| | 8431 | |
|
| | 8432 | | /// <summary> |
| | 8433 | | /// Deletes a prebuilt domain's models in a version of the application. |
| | 8434 | | /// </summary> |
| | 8435 | | /// <param name='appId'> |
| | 8436 | | /// The application ID. |
| | 8437 | | /// </param> |
| | 8438 | | /// <param name='versionId'> |
| | 8439 | | /// The version ID. |
| | 8440 | | /// </param> |
| | 8441 | | /// <param name='domainName'> |
| | 8442 | | /// Domain name. |
| | 8443 | | /// </param> |
| | 8444 | | /// <param name='customHeaders'> |
| | 8445 | | /// Headers that will be added to request. |
| | 8446 | | /// </param> |
| | 8447 | | /// <param name='cancellationToken'> |
| | 8448 | | /// The cancellation token. |
| | 8449 | | /// </param> |
| | 8450 | | /// <exception cref="ErrorResponseException"> |
| | 8451 | | /// Thrown when the operation returned an invalid status code |
| | 8452 | | /// </exception> |
| | 8453 | | /// <exception cref="SerializationException"> |
| | 8454 | | /// Thrown when unable to deserialize the response |
| | 8455 | | /// </exception> |
| | 8456 | | /// <exception cref="ValidationException"> |
| | 8457 | | /// Thrown when a required parameter is null |
| | 8458 | | /// </exception> |
| | 8459 | | /// <exception cref="System.ArgumentNullException"> |
| | 8460 | | /// Thrown when a required parameter is null |
| | 8461 | | /// </exception> |
| | 8462 | | /// <return> |
| | 8463 | | /// A response object containing the response body and response headers. |
| | 8464 | | /// </return> |
| | 8465 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteCustomPrebuiltDomainWithHttpMessagesAsync(System |
| | 8466 | | { |
| 5 | 8467 | | if (Client.Endpoint == null) |
| | 8468 | | { |
| 0 | 8469 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 8470 | | } |
| 5 | 8471 | | if (versionId == null) |
| | 8472 | | { |
| 0 | 8473 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 8474 | | } |
| 5 | 8475 | | if (domainName == null) |
| | 8476 | | { |
| 0 | 8477 | | throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); |
| | 8478 | | } |
| | 8479 | | // Tracing |
| 5 | 8480 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 5 | 8481 | | string _invocationId = null; |
| 5 | 8482 | | if (_shouldTrace) |
| | 8483 | | { |
| 0 | 8484 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 8485 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 8486 | | tracingParameters.Add("appId", appId); |
| 0 | 8487 | | tracingParameters.Add("versionId", versionId); |
| 0 | 8488 | | tracingParameters.Add("domainName", domainName); |
| 0 | 8489 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 8490 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteCustomPrebuiltDomain", tracingParameters); |
| | 8491 | | } |
| | 8492 | | // Construct URL |
| 5 | 8493 | | var _baseUrl = Client.BaseUri; |
| 5 | 8494 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil |
| 5 | 8495 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 5 | 8496 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 5 | 8497 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 5 | 8498 | | _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); |
| | 8499 | | // Create HTTP transport objects |
| 5 | 8500 | | var _httpRequest = new HttpRequestMessage(); |
| 5 | 8501 | | HttpResponseMessage _httpResponse = null; |
| 5 | 8502 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 5 | 8503 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 8504 | | // Set Headers |
| | 8505 | |
|
| | 8506 | |
|
| 5 | 8507 | | if (customHeaders != null) |
| | 8508 | | { |
| 0 | 8509 | | foreach(var _header in customHeaders) |
| | 8510 | | { |
| 0 | 8511 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 8512 | | { |
| 0 | 8513 | | _httpRequest.Headers.Remove(_header.Key); |
| | 8514 | | } |
| 0 | 8515 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 8516 | | } |
| | 8517 | | } |
| | 8518 | |
|
| | 8519 | | // Serialize Request |
| 5 | 8520 | | string _requestContent = null; |
| | 8521 | | // Set Credentials |
| 5 | 8522 | | if (Client.Credentials != null) |
| | 8523 | | { |
| 5 | 8524 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 8525 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 8526 | | } |
| | 8527 | | // Send Request |
| 5 | 8528 | | if (_shouldTrace) |
| | 8529 | | { |
| 0 | 8530 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 8531 | | } |
| 5 | 8532 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 8533 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 5 | 8534 | | if (_shouldTrace) |
| | 8535 | | { |
| 0 | 8536 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 8537 | | } |
| 5 | 8538 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 5 | 8539 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 8540 | | string _responseContent = null; |
| 5 | 8541 | | if ((int)_statusCode != 200) |
| | 8542 | | { |
| 0 | 8543 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 8544 | | try |
| | 8545 | | { |
| 0 | 8546 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 8547 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 8548 | | if (_errorBody != null) |
| | 8549 | | { |
| 0 | 8550 | | ex.Body = _errorBody; |
| | 8551 | | } |
| 0 | 8552 | | } |
| 0 | 8553 | | catch (JsonException) |
| | 8554 | | { |
| | 8555 | | // Ignore the exception |
| 0 | 8556 | | } |
| 0 | 8557 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 8558 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 8559 | | if (_shouldTrace) |
| | 8560 | | { |
| 0 | 8561 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 8562 | | } |
| 0 | 8563 | | _httpRequest.Dispose(); |
| 0 | 8564 | | if (_httpResponse != null) |
| | 8565 | | { |
| 0 | 8566 | | _httpResponse.Dispose(); |
| | 8567 | | } |
| 0 | 8568 | | throw ex; |
| | 8569 | | } |
| | 8570 | | // Create Result |
| 5 | 8571 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 5 | 8572 | | _result.Request = _httpRequest; |
| 5 | 8573 | | _result.Response = _httpResponse; |
| | 8574 | | // Deserialize Response |
| 5 | 8575 | | if ((int)_statusCode == 200) |
| | 8576 | | { |
| 5 | 8577 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 8578 | | try |
| | 8579 | | { |
| 5 | 8580 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 5 | 8581 | | } |
| 0 | 8582 | | catch (JsonException ex) |
| | 8583 | | { |
| 0 | 8584 | | _httpRequest.Dispose(); |
| 0 | 8585 | | if (_httpResponse != null) |
| | 8586 | | { |
| 0 | 8587 | | _httpResponse.Dispose(); |
| | 8588 | | } |
| 0 | 8589 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 8590 | | } |
| | 8591 | | } |
| 5 | 8592 | | if (_shouldTrace) |
| | 8593 | | { |
| 0 | 8594 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 8595 | | } |
| 5 | 8596 | | return _result; |
| 5 | 8597 | | } |
| | 8598 | |
|
| | 8599 | | /// <summary> |
| | 8600 | | /// Creates a single child in an existing entity model hierarchy in a version |
| | 8601 | | /// of the application. |
| | 8602 | | /// </summary> |
| | 8603 | | /// <param name='appId'> |
| | 8604 | | /// The application ID. |
| | 8605 | | /// </param> |
| | 8606 | | /// <param name='versionId'> |
| | 8607 | | /// The version ID. |
| | 8608 | | /// </param> |
| | 8609 | | /// <param name='entityId'> |
| | 8610 | | /// The entity extractor ID. |
| | 8611 | | /// </param> |
| | 8612 | | /// <param name='childEntityModelCreateObject'> |
| | 8613 | | /// A model object containing the name of the new child model and its children. |
| | 8614 | | /// </param> |
| | 8615 | | /// <param name='customHeaders'> |
| | 8616 | | /// Headers that will be added to request. |
| | 8617 | | /// </param> |
| | 8618 | | /// <param name='cancellationToken'> |
| | 8619 | | /// The cancellation token. |
| | 8620 | | /// </param> |
| | 8621 | | /// <exception cref="ErrorResponseException"> |
| | 8622 | | /// Thrown when the operation returned an invalid status code |
| | 8623 | | /// </exception> |
| | 8624 | | /// <exception cref="SerializationException"> |
| | 8625 | | /// Thrown when unable to deserialize the response |
| | 8626 | | /// </exception> |
| | 8627 | | /// <exception cref="ValidationException"> |
| | 8628 | | /// Thrown when a required parameter is null |
| | 8629 | | /// </exception> |
| | 8630 | | /// <exception cref="System.ArgumentNullException"> |
| | 8631 | | /// Thrown when a required parameter is null |
| | 8632 | | /// </exception> |
| | 8633 | | /// <return> |
| | 8634 | | /// A response object containing the response body and response headers. |
| | 8635 | | /// </return> |
| | 8636 | | public async Task<HttpOperationResponse<System.Guid>> AddEntityChildWithHttpMessagesAsync(System.Guid appId, str |
| | 8637 | | { |
| 3 | 8638 | | if (Client.Endpoint == null) |
| | 8639 | | { |
| 0 | 8640 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 8641 | | } |
| 3 | 8642 | | if (versionId == null) |
| | 8643 | | { |
| 0 | 8644 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 8645 | | } |
| 3 | 8646 | | if (childEntityModelCreateObject == null) |
| | 8647 | | { |
| 0 | 8648 | | throw new ValidationException(ValidationRules.CannotBeNull, "childEntityModelCreateObject"); |
| | 8649 | | } |
| | 8650 | | // Tracing |
| 3 | 8651 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 3 | 8652 | | string _invocationId = null; |
| 3 | 8653 | | if (_shouldTrace) |
| | 8654 | | { |
| 0 | 8655 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 8656 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 8657 | | tracingParameters.Add("appId", appId); |
| 0 | 8658 | | tracingParameters.Add("versionId", versionId); |
| 0 | 8659 | | tracingParameters.Add("entityId", entityId); |
| 0 | 8660 | | tracingParameters.Add("childEntityModelCreateObject", childEntityModelCreateObject); |
| 0 | 8661 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 8662 | | ServiceClientTracing.Enter(_invocationId, this, "AddEntityChild", tracingParameters); |
| | 8663 | | } |
| | 8664 | | // Construct URL |
| 3 | 8665 | | var _baseUrl = Client.BaseUri; |
| 3 | 8666 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent |
| 3 | 8667 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 3 | 8668 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 3 | 8669 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 3 | 8670 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 8671 | | // Create HTTP transport objects |
| 3 | 8672 | | var _httpRequest = new HttpRequestMessage(); |
| 3 | 8673 | | HttpResponseMessage _httpResponse = null; |
| 3 | 8674 | | _httpRequest.Method = new HttpMethod("POST"); |
| 3 | 8675 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 8676 | | // Set Headers |
| | 8677 | |
|
| | 8678 | |
|
| 3 | 8679 | | if (customHeaders != null) |
| | 8680 | | { |
| 0 | 8681 | | foreach(var _header in customHeaders) |
| | 8682 | | { |
| 0 | 8683 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 8684 | | { |
| 0 | 8685 | | _httpRequest.Headers.Remove(_header.Key); |
| | 8686 | | } |
| 0 | 8687 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 8688 | | } |
| | 8689 | | } |
| | 8690 | |
|
| | 8691 | | // Serialize Request |
| 3 | 8692 | | string _requestContent = null; |
| 3 | 8693 | | if(childEntityModelCreateObject != null) |
| | 8694 | | { |
| 3 | 8695 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(childEntityModelCreateObject, Clien |
| 3 | 8696 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 3 | 8697 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 8698 | | } |
| | 8699 | | // Set Credentials |
| 3 | 8700 | | if (Client.Credentials != null) |
| | 8701 | | { |
| 3 | 8702 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 8703 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 8704 | | } |
| | 8705 | | // Send Request |
| 3 | 8706 | | if (_shouldTrace) |
| | 8707 | | { |
| 0 | 8708 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 8709 | | } |
| 3 | 8710 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 8711 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 3 | 8712 | | if (_shouldTrace) |
| | 8713 | | { |
| 0 | 8714 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 8715 | | } |
| 3 | 8716 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 3 | 8717 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 8718 | | string _responseContent = null; |
| 3 | 8719 | | if ((int)_statusCode != 201) |
| | 8720 | | { |
| 0 | 8721 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 8722 | | try |
| | 8723 | | { |
| 0 | 8724 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 8725 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 8726 | | if (_errorBody != null) |
| | 8727 | | { |
| 0 | 8728 | | ex.Body = _errorBody; |
| | 8729 | | } |
| 0 | 8730 | | } |
| 0 | 8731 | | catch (JsonException) |
| | 8732 | | { |
| | 8733 | | // Ignore the exception |
| 0 | 8734 | | } |
| 0 | 8735 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 8736 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 8737 | | if (_shouldTrace) |
| | 8738 | | { |
| 0 | 8739 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 8740 | | } |
| 0 | 8741 | | _httpRequest.Dispose(); |
| 0 | 8742 | | if (_httpResponse != null) |
| | 8743 | | { |
| 0 | 8744 | | _httpResponse.Dispose(); |
| | 8745 | | } |
| 0 | 8746 | | throw ex; |
| | 8747 | | } |
| | 8748 | | // Create Result |
| 3 | 8749 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 3 | 8750 | | _result.Request = _httpRequest; |
| 3 | 8751 | | _result.Response = _httpResponse; |
| | 8752 | | // Deserialize Response |
| 3 | 8753 | | if ((int)_statusCode == 201) |
| | 8754 | | { |
| 3 | 8755 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 8756 | | try |
| | 8757 | | { |
| 3 | 8758 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 3 | 8759 | | } |
| 0 | 8760 | | catch (JsonException ex) |
| | 8761 | | { |
| 0 | 8762 | | _httpRequest.Dispose(); |
| 0 | 8763 | | if (_httpResponse != null) |
| | 8764 | | { |
| 0 | 8765 | | _httpResponse.Dispose(); |
| | 8766 | | } |
| 0 | 8767 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 8768 | | } |
| | 8769 | | } |
| 3 | 8770 | | if (_shouldTrace) |
| | 8771 | | { |
| 0 | 8772 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 8773 | | } |
| 3 | 8774 | | return _result; |
| 3 | 8775 | | } |
| | 8776 | |
|
| | 8777 | | /// <summary> |
| | 8778 | | /// Gets information about the child's model contained in an hierarchical |
| | 8779 | | /// entity child model in a version of the application. |
| | 8780 | | /// </summary> |
| | 8781 | | /// <param name='appId'> |
| | 8782 | | /// The application ID. |
| | 8783 | | /// </param> |
| | 8784 | | /// <param name='versionId'> |
| | 8785 | | /// The version ID. |
| | 8786 | | /// </param> |
| | 8787 | | /// <param name='hEntityId'> |
| | 8788 | | /// The hierarchical entity extractor ID. |
| | 8789 | | /// </param> |
| | 8790 | | /// <param name='hChildId'> |
| | 8791 | | /// The hierarchical entity extractor child ID. |
| | 8792 | | /// </param> |
| | 8793 | | /// <param name='customHeaders'> |
| | 8794 | | /// Headers that will be added to request. |
| | 8795 | | /// </param> |
| | 8796 | | /// <param name='cancellationToken'> |
| | 8797 | | /// The cancellation token. |
| | 8798 | | /// </param> |
| | 8799 | | /// <exception cref="ErrorResponseException"> |
| | 8800 | | /// Thrown when the operation returned an invalid status code |
| | 8801 | | /// </exception> |
| | 8802 | | /// <exception cref="SerializationException"> |
| | 8803 | | /// Thrown when unable to deserialize the response |
| | 8804 | | /// </exception> |
| | 8805 | | /// <exception cref="ValidationException"> |
| | 8806 | | /// Thrown when a required parameter is null |
| | 8807 | | /// </exception> |
| | 8808 | | /// <exception cref="System.ArgumentNullException"> |
| | 8809 | | /// Thrown when a required parameter is null |
| | 8810 | | /// </exception> |
| | 8811 | | /// <return> |
| | 8812 | | /// A response object containing the response body and response headers. |
| | 8813 | | /// </return> |
| | 8814 | | public async Task<HttpOperationResponse<HierarchicalChildEntity>> GetHierarchicalEntityChildWithHttpMessagesAsyn |
| | 8815 | | { |
| 0 | 8816 | | if (Client.Endpoint == null) |
| | 8817 | | { |
| 0 | 8818 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 8819 | | } |
| 0 | 8820 | | if (versionId == null) |
| | 8821 | | { |
| 0 | 8822 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 8823 | | } |
| | 8824 | | // Tracing |
| 0 | 8825 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 8826 | | string _invocationId = null; |
| 0 | 8827 | | if (_shouldTrace) |
| | 8828 | | { |
| 0 | 8829 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 8830 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 8831 | | tracingParameters.Add("appId", appId); |
| 0 | 8832 | | tracingParameters.Add("versionId", versionId); |
| 0 | 8833 | | tracingParameters.Add("hEntityId", hEntityId); |
| 0 | 8834 | | tracingParameters.Add("hChildId", hChildId); |
| 0 | 8835 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 8836 | | ServiceClientTracing.Enter(_invocationId, this, "GetHierarchicalEntityChild", tracingParameters); |
| | 8837 | | } |
| | 8838 | | // Construct URL |
| 0 | 8839 | | var _baseUrl = Client.BaseUri; |
| 0 | 8840 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale |
| 0 | 8841 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 8842 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 8843 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 8844 | | _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| 0 | 8845 | | _url = _url.Replace("{hChildId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 8846 | | // Create HTTP transport objects |
| 0 | 8847 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 8848 | | HttpResponseMessage _httpResponse = null; |
| 0 | 8849 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 8850 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 8851 | | // Set Headers |
| | 8852 | |
|
| | 8853 | |
|
| 0 | 8854 | | if (customHeaders != null) |
| | 8855 | | { |
| 0 | 8856 | | foreach(var _header in customHeaders) |
| | 8857 | | { |
| 0 | 8858 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 8859 | | { |
| 0 | 8860 | | _httpRequest.Headers.Remove(_header.Key); |
| | 8861 | | } |
| 0 | 8862 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 8863 | | } |
| | 8864 | | } |
| | 8865 | |
|
| | 8866 | | // Serialize Request |
| 0 | 8867 | | string _requestContent = null; |
| | 8868 | | // Set Credentials |
| 0 | 8869 | | if (Client.Credentials != null) |
| | 8870 | | { |
| 0 | 8871 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 8872 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 8873 | | } |
| | 8874 | | // Send Request |
| 0 | 8875 | | if (_shouldTrace) |
| | 8876 | | { |
| 0 | 8877 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 8878 | | } |
| 0 | 8879 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 8880 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 8881 | | if (_shouldTrace) |
| | 8882 | | { |
| 0 | 8883 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 8884 | | } |
| 0 | 8885 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 8886 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 8887 | | string _responseContent = null; |
| 0 | 8888 | | if ((int)_statusCode != 200) |
| | 8889 | | { |
| 0 | 8890 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 8891 | | try |
| | 8892 | | { |
| 0 | 8893 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 8894 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 8895 | | if (_errorBody != null) |
| | 8896 | | { |
| 0 | 8897 | | ex.Body = _errorBody; |
| | 8898 | | } |
| 0 | 8899 | | } |
| 0 | 8900 | | catch (JsonException) |
| | 8901 | | { |
| | 8902 | | // Ignore the exception |
| 0 | 8903 | | } |
| 0 | 8904 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 8905 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 8906 | | if (_shouldTrace) |
| | 8907 | | { |
| 0 | 8908 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 8909 | | } |
| 0 | 8910 | | _httpRequest.Dispose(); |
| 0 | 8911 | | if (_httpResponse != null) |
| | 8912 | | { |
| 0 | 8913 | | _httpResponse.Dispose(); |
| | 8914 | | } |
| 0 | 8915 | | throw ex; |
| | 8916 | | } |
| | 8917 | | // Create Result |
| 0 | 8918 | | var _result = new HttpOperationResponse<HierarchicalChildEntity>(); |
| 0 | 8919 | | _result.Request = _httpRequest; |
| 0 | 8920 | | _result.Response = _httpResponse; |
| | 8921 | | // Deserialize Response |
| 0 | 8922 | | if ((int)_statusCode == 200) |
| | 8923 | | { |
| 0 | 8924 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 8925 | | try |
| | 8926 | | { |
| 0 | 8927 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<HierarchicalChildEntity>(_respon |
| 0 | 8928 | | } |
| 0 | 8929 | | catch (JsonException ex) |
| | 8930 | | { |
| 0 | 8931 | | _httpRequest.Dispose(); |
| 0 | 8932 | | if (_httpResponse != null) |
| | 8933 | | { |
| 0 | 8934 | | _httpResponse.Dispose(); |
| | 8935 | | } |
| 0 | 8936 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 8937 | | } |
| | 8938 | | } |
| 0 | 8939 | | if (_shouldTrace) |
| | 8940 | | { |
| 0 | 8941 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 8942 | | } |
| 0 | 8943 | | return _result; |
| 0 | 8944 | | } |
| | 8945 | |
|
| | 8946 | | /// <summary> |
| | 8947 | | /// Renames a single child in an existing hierarchical entity model in a |
| | 8948 | | /// version of the application. |
| | 8949 | | /// </summary> |
| | 8950 | | /// <param name='appId'> |
| | 8951 | | /// The application ID. |
| | 8952 | | /// </param> |
| | 8953 | | /// <param name='versionId'> |
| | 8954 | | /// The version ID. |
| | 8955 | | /// </param> |
| | 8956 | | /// <param name='hEntityId'> |
| | 8957 | | /// The hierarchical entity extractor ID. |
| | 8958 | | /// </param> |
| | 8959 | | /// <param name='hChildId'> |
| | 8960 | | /// The hierarchical entity extractor child ID. |
| | 8961 | | /// </param> |
| | 8962 | | /// <param name='hierarchicalChildModelUpdateObject'> |
| | 8963 | | /// Model object containing new name of the hierarchical entity child. |
| | 8964 | | /// </param> |
| | 8965 | | /// <param name='customHeaders'> |
| | 8966 | | /// Headers that will be added to request. |
| | 8967 | | /// </param> |
| | 8968 | | /// <param name='cancellationToken'> |
| | 8969 | | /// The cancellation token. |
| | 8970 | | /// </param> |
| | 8971 | | /// <exception cref="ErrorResponseException"> |
| | 8972 | | /// Thrown when the operation returned an invalid status code |
| | 8973 | | /// </exception> |
| | 8974 | | /// <exception cref="SerializationException"> |
| | 8975 | | /// Thrown when unable to deserialize the response |
| | 8976 | | /// </exception> |
| | 8977 | | /// <exception cref="ValidationException"> |
| | 8978 | | /// Thrown when a required parameter is null |
| | 8979 | | /// </exception> |
| | 8980 | | /// <exception cref="System.ArgumentNullException"> |
| | 8981 | | /// Thrown when a required parameter is null |
| | 8982 | | /// </exception> |
| | 8983 | | /// <return> |
| | 8984 | | /// A response object containing the response body and response headers. |
| | 8985 | | /// </return> |
| | 8986 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateHierarchicalEntityChildWithHttpMessagesAsync(Sys |
| | 8987 | | { |
| 0 | 8988 | | if (Client.Endpoint == null) |
| | 8989 | | { |
| 0 | 8990 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 8991 | | } |
| 0 | 8992 | | if (versionId == null) |
| | 8993 | | { |
| 0 | 8994 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 8995 | | } |
| 0 | 8996 | | if (hierarchicalChildModelUpdateObject == null) |
| | 8997 | | { |
| 0 | 8998 | | throw new ValidationException(ValidationRules.CannotBeNull, "hierarchicalChildModelUpdateObject"); |
| | 8999 | | } |
| | 9000 | | // Tracing |
| 0 | 9001 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 9002 | | string _invocationId = null; |
| 0 | 9003 | | if (_shouldTrace) |
| | 9004 | | { |
| 0 | 9005 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 9006 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 9007 | | tracingParameters.Add("appId", appId); |
| 0 | 9008 | | tracingParameters.Add("versionId", versionId); |
| 0 | 9009 | | tracingParameters.Add("hEntityId", hEntityId); |
| 0 | 9010 | | tracingParameters.Add("hChildId", hChildId); |
| 0 | 9011 | | tracingParameters.Add("hierarchicalChildModelUpdateObject", hierarchicalChildModelUpdateObject); |
| 0 | 9012 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 9013 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateHierarchicalEntityChild", tracingParameters); |
| | 9014 | | } |
| | 9015 | | // Construct URL |
| 0 | 9016 | | var _baseUrl = Client.BaseUri; |
| 0 | 9017 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale |
| 0 | 9018 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 9019 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 9020 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 9021 | | _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| 0 | 9022 | | _url = _url.Replace("{hChildId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 9023 | | // Create HTTP transport objects |
| 0 | 9024 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 9025 | | HttpResponseMessage _httpResponse = null; |
| 0 | 9026 | | _httpRequest.Method = new HttpMethod("PATCH"); |
| 0 | 9027 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 9028 | | // Set Headers |
| | 9029 | |
|
| | 9030 | |
|
| 0 | 9031 | | if (customHeaders != null) |
| | 9032 | | { |
| 0 | 9033 | | foreach(var _header in customHeaders) |
| | 9034 | | { |
| 0 | 9035 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 9036 | | { |
| 0 | 9037 | | _httpRequest.Headers.Remove(_header.Key); |
| | 9038 | | } |
| 0 | 9039 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 9040 | | } |
| | 9041 | | } |
| | 9042 | |
|
| | 9043 | | // Serialize Request |
| 0 | 9044 | | string _requestContent = null; |
| 0 | 9045 | | if(hierarchicalChildModelUpdateObject != null) |
| | 9046 | | { |
| 0 | 9047 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(hierarchicalChildModelUpdateObject, |
| 0 | 9048 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 9049 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 9050 | | } |
| | 9051 | | // Set Credentials |
| 0 | 9052 | | if (Client.Credentials != null) |
| | 9053 | | { |
| 0 | 9054 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 9055 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 9056 | | } |
| | 9057 | | // Send Request |
| 0 | 9058 | | if (_shouldTrace) |
| | 9059 | | { |
| 0 | 9060 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 9061 | | } |
| 0 | 9062 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 9063 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 9064 | | if (_shouldTrace) |
| | 9065 | | { |
| 0 | 9066 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 9067 | | } |
| 0 | 9068 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 9069 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 9070 | | string _responseContent = null; |
| 0 | 9071 | | if ((int)_statusCode != 200) |
| | 9072 | | { |
| 0 | 9073 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 9074 | | try |
| | 9075 | | { |
| 0 | 9076 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 9077 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 9078 | | if (_errorBody != null) |
| | 9079 | | { |
| 0 | 9080 | | ex.Body = _errorBody; |
| | 9081 | | } |
| 0 | 9082 | | } |
| 0 | 9083 | | catch (JsonException) |
| | 9084 | | { |
| | 9085 | | // Ignore the exception |
| 0 | 9086 | | } |
| 0 | 9087 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 9088 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 9089 | | if (_shouldTrace) |
| | 9090 | | { |
| 0 | 9091 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 9092 | | } |
| 0 | 9093 | | _httpRequest.Dispose(); |
| 0 | 9094 | | if (_httpResponse != null) |
| | 9095 | | { |
| 0 | 9096 | | _httpResponse.Dispose(); |
| | 9097 | | } |
| 0 | 9098 | | throw ex; |
| | 9099 | | } |
| | 9100 | | // Create Result |
| 0 | 9101 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 0 | 9102 | | _result.Request = _httpRequest; |
| 0 | 9103 | | _result.Response = _httpResponse; |
| | 9104 | | // Deserialize Response |
| 0 | 9105 | | if ((int)_statusCode == 200) |
| | 9106 | | { |
| 0 | 9107 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 9108 | | try |
| | 9109 | | { |
| 0 | 9110 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 0 | 9111 | | } |
| 0 | 9112 | | catch (JsonException ex) |
| | 9113 | | { |
| 0 | 9114 | | _httpRequest.Dispose(); |
| 0 | 9115 | | if (_httpResponse != null) |
| | 9116 | | { |
| 0 | 9117 | | _httpResponse.Dispose(); |
| | 9118 | | } |
| 0 | 9119 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 9120 | | } |
| | 9121 | | } |
| 0 | 9122 | | if (_shouldTrace) |
| | 9123 | | { |
| 0 | 9124 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 9125 | | } |
| 0 | 9126 | | return _result; |
| 0 | 9127 | | } |
| | 9128 | |
|
| | 9129 | | /// <summary> |
| | 9130 | | /// Deletes a hierarchical entity extractor child in a version of the |
| | 9131 | | /// application. |
| | 9132 | | /// </summary> |
| | 9133 | | /// <param name='appId'> |
| | 9134 | | /// The application ID. |
| | 9135 | | /// </param> |
| | 9136 | | /// <param name='versionId'> |
| | 9137 | | /// The version ID. |
| | 9138 | | /// </param> |
| | 9139 | | /// <param name='hEntityId'> |
| | 9140 | | /// The hierarchical entity extractor ID. |
| | 9141 | | /// </param> |
| | 9142 | | /// <param name='hChildId'> |
| | 9143 | | /// The hierarchical entity extractor child ID. |
| | 9144 | | /// </param> |
| | 9145 | | /// <param name='customHeaders'> |
| | 9146 | | /// Headers that will be added to request. |
| | 9147 | | /// </param> |
| | 9148 | | /// <param name='cancellationToken'> |
| | 9149 | | /// The cancellation token. |
| | 9150 | | /// </param> |
| | 9151 | | /// <exception cref="ErrorResponseException"> |
| | 9152 | | /// Thrown when the operation returned an invalid status code |
| | 9153 | | /// </exception> |
| | 9154 | | /// <exception cref="SerializationException"> |
| | 9155 | | /// Thrown when unable to deserialize the response |
| | 9156 | | /// </exception> |
| | 9157 | | /// <exception cref="ValidationException"> |
| | 9158 | | /// Thrown when a required parameter is null |
| | 9159 | | /// </exception> |
| | 9160 | | /// <exception cref="System.ArgumentNullException"> |
| | 9161 | | /// Thrown when a required parameter is null |
| | 9162 | | /// </exception> |
| | 9163 | | /// <return> |
| | 9164 | | /// A response object containing the response body and response headers. |
| | 9165 | | /// </return> |
| | 9166 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteHierarchicalEntityChildWithHttpMessagesAsync(Sys |
| | 9167 | | { |
| 0 | 9168 | | if (Client.Endpoint == null) |
| | 9169 | | { |
| 0 | 9170 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 9171 | | } |
| 0 | 9172 | | if (versionId == null) |
| | 9173 | | { |
| 0 | 9174 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 9175 | | } |
| | 9176 | | // Tracing |
| 0 | 9177 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 9178 | | string _invocationId = null; |
| 0 | 9179 | | if (_shouldTrace) |
| | 9180 | | { |
| 0 | 9181 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 9182 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 9183 | | tracingParameters.Add("appId", appId); |
| 0 | 9184 | | tracingParameters.Add("versionId", versionId); |
| 0 | 9185 | | tracingParameters.Add("hEntityId", hEntityId); |
| 0 | 9186 | | tracingParameters.Add("hChildId", hChildId); |
| 0 | 9187 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 9188 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteHierarchicalEntityChild", tracingParameters); |
| | 9189 | | } |
| | 9190 | | // Construct URL |
| 0 | 9191 | | var _baseUrl = Client.BaseUri; |
| 0 | 9192 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale |
| 0 | 9193 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 9194 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 9195 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 9196 | | _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| 0 | 9197 | | _url = _url.Replace("{hChildId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 9198 | | // Create HTTP transport objects |
| 0 | 9199 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 9200 | | HttpResponseMessage _httpResponse = null; |
| 0 | 9201 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 0 | 9202 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 9203 | | // Set Headers |
| | 9204 | |
|
| | 9205 | |
|
| 0 | 9206 | | if (customHeaders != null) |
| | 9207 | | { |
| 0 | 9208 | | foreach(var _header in customHeaders) |
| | 9209 | | { |
| 0 | 9210 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 9211 | | { |
| 0 | 9212 | | _httpRequest.Headers.Remove(_header.Key); |
| | 9213 | | } |
| 0 | 9214 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 9215 | | } |
| | 9216 | | } |
| | 9217 | |
|
| | 9218 | | // Serialize Request |
| 0 | 9219 | | string _requestContent = null; |
| | 9220 | | // Set Credentials |
| 0 | 9221 | | if (Client.Credentials != null) |
| | 9222 | | { |
| 0 | 9223 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 9224 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 9225 | | } |
| | 9226 | | // Send Request |
| 0 | 9227 | | if (_shouldTrace) |
| | 9228 | | { |
| 0 | 9229 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 9230 | | } |
| 0 | 9231 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 9232 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 9233 | | if (_shouldTrace) |
| | 9234 | | { |
| 0 | 9235 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 9236 | | } |
| 0 | 9237 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 9238 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 9239 | | string _responseContent = null; |
| 0 | 9240 | | if ((int)_statusCode != 200) |
| | 9241 | | { |
| 0 | 9242 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 9243 | | try |
| | 9244 | | { |
| 0 | 9245 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 9246 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 9247 | | if (_errorBody != null) |
| | 9248 | | { |
| 0 | 9249 | | ex.Body = _errorBody; |
| | 9250 | | } |
| 0 | 9251 | | } |
| 0 | 9252 | | catch (JsonException) |
| | 9253 | | { |
| | 9254 | | // Ignore the exception |
| 0 | 9255 | | } |
| 0 | 9256 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 9257 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 9258 | | if (_shouldTrace) |
| | 9259 | | { |
| 0 | 9260 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 9261 | | } |
| 0 | 9262 | | _httpRequest.Dispose(); |
| 0 | 9263 | | if (_httpResponse != null) |
| | 9264 | | { |
| 0 | 9265 | | _httpResponse.Dispose(); |
| | 9266 | | } |
| 0 | 9267 | | throw ex; |
| | 9268 | | } |
| | 9269 | | // Create Result |
| 0 | 9270 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 0 | 9271 | | _result.Request = _httpRequest; |
| 0 | 9272 | | _result.Response = _httpResponse; |
| | 9273 | | // Deserialize Response |
| 0 | 9274 | | if ((int)_statusCode == 200) |
| | 9275 | | { |
| 0 | 9276 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 9277 | | try |
| | 9278 | | { |
| 0 | 9279 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 0 | 9280 | | } |
| 0 | 9281 | | catch (JsonException ex) |
| | 9282 | | { |
| 0 | 9283 | | _httpRequest.Dispose(); |
| 0 | 9284 | | if (_httpResponse != null) |
| | 9285 | | { |
| 0 | 9286 | | _httpResponse.Dispose(); |
| | 9287 | | } |
| 0 | 9288 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 9289 | | } |
| | 9290 | | } |
| 0 | 9291 | | if (_shouldTrace) |
| | 9292 | | { |
| 0 | 9293 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 9294 | | } |
| 0 | 9295 | | return _result; |
| 0 | 9296 | | } |
| | 9297 | |
|
| | 9298 | | /// <summary> |
| | 9299 | | /// Creates a single child in an existing composite entity model in a version |
| | 9300 | | /// of the application. |
| | 9301 | | /// </summary> |
| | 9302 | | /// <param name='appId'> |
| | 9303 | | /// The application ID. |
| | 9304 | | /// </param> |
| | 9305 | | /// <param name='versionId'> |
| | 9306 | | /// The version ID. |
| | 9307 | | /// </param> |
| | 9308 | | /// <param name='cEntityId'> |
| | 9309 | | /// The composite entity extractor ID. |
| | 9310 | | /// </param> |
| | 9311 | | /// <param name='compositeChildModelCreateObject'> |
| | 9312 | | /// A model object containing the name of the new composite child model. |
| | 9313 | | /// </param> |
| | 9314 | | /// <param name='customHeaders'> |
| | 9315 | | /// Headers that will be added to request. |
| | 9316 | | /// </param> |
| | 9317 | | /// <param name='cancellationToken'> |
| | 9318 | | /// The cancellation token. |
| | 9319 | | /// </param> |
| | 9320 | | /// <exception cref="ErrorResponseException"> |
| | 9321 | | /// Thrown when the operation returned an invalid status code |
| | 9322 | | /// </exception> |
| | 9323 | | /// <exception cref="SerializationException"> |
| | 9324 | | /// Thrown when unable to deserialize the response |
| | 9325 | | /// </exception> |
| | 9326 | | /// <exception cref="ValidationException"> |
| | 9327 | | /// Thrown when a required parameter is null |
| | 9328 | | /// </exception> |
| | 9329 | | /// <exception cref="System.ArgumentNullException"> |
| | 9330 | | /// Thrown when a required parameter is null |
| | 9331 | | /// </exception> |
| | 9332 | | /// <return> |
| | 9333 | | /// A response object containing the response body and response headers. |
| | 9334 | | /// </return> |
| | 9335 | | public async Task<HttpOperationResponse<System.Guid>> AddCompositeEntityChildWithHttpMessagesAsync(System.Guid a |
| | 9336 | | { |
| 0 | 9337 | | if (Client.Endpoint == null) |
| | 9338 | | { |
| 0 | 9339 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 9340 | | } |
| 0 | 9341 | | if (versionId == null) |
| | 9342 | | { |
| 0 | 9343 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 9344 | | } |
| 0 | 9345 | | if (compositeChildModelCreateObject == null) |
| | 9346 | | { |
| 0 | 9347 | | throw new ValidationException(ValidationRules.CannotBeNull, "compositeChildModelCreateObject"); |
| | 9348 | | } |
| | 9349 | | // Tracing |
| 0 | 9350 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 9351 | | string _invocationId = null; |
| 0 | 9352 | | if (_shouldTrace) |
| | 9353 | | { |
| 0 | 9354 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 9355 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 9356 | | tracingParameters.Add("appId", appId); |
| 0 | 9357 | | tracingParameters.Add("versionId", versionId); |
| 0 | 9358 | | tracingParameters.Add("cEntityId", cEntityId); |
| 0 | 9359 | | tracingParameters.Add("compositeChildModelCreateObject", compositeChildModelCreateObject); |
| 0 | 9360 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 9361 | | ServiceClientTracing.Enter(_invocationId, this, "AddCompositeEntityChild", tracingParameters); |
| | 9362 | | } |
| | 9363 | | // Construct URL |
| 0 | 9364 | | var _baseUrl = Client.BaseUri; |
| 0 | 9365 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti |
| 0 | 9366 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 9367 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 9368 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 9369 | | _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| | 9370 | | // Create HTTP transport objects |
| 0 | 9371 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 9372 | | HttpResponseMessage _httpResponse = null; |
| 0 | 9373 | | _httpRequest.Method = new HttpMethod("POST"); |
| 0 | 9374 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 9375 | | // Set Headers |
| | 9376 | |
|
| | 9377 | |
|
| 0 | 9378 | | if (customHeaders != null) |
| | 9379 | | { |
| 0 | 9380 | | foreach(var _header in customHeaders) |
| | 9381 | | { |
| 0 | 9382 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 9383 | | { |
| 0 | 9384 | | _httpRequest.Headers.Remove(_header.Key); |
| | 9385 | | } |
| 0 | 9386 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 9387 | | } |
| | 9388 | | } |
| | 9389 | |
|
| | 9390 | | // Serialize Request |
| 0 | 9391 | | string _requestContent = null; |
| 0 | 9392 | | if(compositeChildModelCreateObject != null) |
| | 9393 | | { |
| 0 | 9394 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(compositeChildModelCreateObject, Cl |
| 0 | 9395 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 9396 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 9397 | | } |
| | 9398 | | // Set Credentials |
| 0 | 9399 | | if (Client.Credentials != null) |
| | 9400 | | { |
| 0 | 9401 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 9402 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 9403 | | } |
| | 9404 | | // Send Request |
| 0 | 9405 | | if (_shouldTrace) |
| | 9406 | | { |
| 0 | 9407 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 9408 | | } |
| 0 | 9409 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 9410 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 9411 | | if (_shouldTrace) |
| | 9412 | | { |
| 0 | 9413 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 9414 | | } |
| 0 | 9415 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 9416 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 9417 | | string _responseContent = null; |
| 0 | 9418 | | if ((int)_statusCode != 201) |
| | 9419 | | { |
| 0 | 9420 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 9421 | | try |
| | 9422 | | { |
| 0 | 9423 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 9424 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 9425 | | if (_errorBody != null) |
| | 9426 | | { |
| 0 | 9427 | | ex.Body = _errorBody; |
| | 9428 | | } |
| 0 | 9429 | | } |
| 0 | 9430 | | catch (JsonException) |
| | 9431 | | { |
| | 9432 | | // Ignore the exception |
| 0 | 9433 | | } |
| 0 | 9434 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 9435 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 9436 | | if (_shouldTrace) |
| | 9437 | | { |
| 0 | 9438 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 9439 | | } |
| 0 | 9440 | | _httpRequest.Dispose(); |
| 0 | 9441 | | if (_httpResponse != null) |
| | 9442 | | { |
| 0 | 9443 | | _httpResponse.Dispose(); |
| | 9444 | | } |
| 0 | 9445 | | throw ex; |
| | 9446 | | } |
| | 9447 | | // Create Result |
| 0 | 9448 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 0 | 9449 | | _result.Request = _httpRequest; |
| 0 | 9450 | | _result.Response = _httpResponse; |
| | 9451 | | // Deserialize Response |
| 0 | 9452 | | if ((int)_statusCode == 201) |
| | 9453 | | { |
| 0 | 9454 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 9455 | | try |
| | 9456 | | { |
| 0 | 9457 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 0 | 9458 | | } |
| 0 | 9459 | | catch (JsonException ex) |
| | 9460 | | { |
| 0 | 9461 | | _httpRequest.Dispose(); |
| 0 | 9462 | | if (_httpResponse != null) |
| | 9463 | | { |
| 0 | 9464 | | _httpResponse.Dispose(); |
| | 9465 | | } |
| 0 | 9466 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 9467 | | } |
| | 9468 | | } |
| 0 | 9469 | | if (_shouldTrace) |
| | 9470 | | { |
| 0 | 9471 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 9472 | | } |
| 0 | 9473 | | return _result; |
| 0 | 9474 | | } |
| | 9475 | |
|
| | 9476 | | /// <summary> |
| | 9477 | | /// Deletes a composite entity extractor child from a version of the |
| | 9478 | | /// application. |
| | 9479 | | /// </summary> |
| | 9480 | | /// <param name='appId'> |
| | 9481 | | /// The application ID. |
| | 9482 | | /// </param> |
| | 9483 | | /// <param name='versionId'> |
| | 9484 | | /// The version ID. |
| | 9485 | | /// </param> |
| | 9486 | | /// <param name='cEntityId'> |
| | 9487 | | /// The composite entity extractor ID. |
| | 9488 | | /// </param> |
| | 9489 | | /// <param name='cChildId'> |
| | 9490 | | /// The hierarchical entity extractor child ID. |
| | 9491 | | /// </param> |
| | 9492 | | /// <param name='customHeaders'> |
| | 9493 | | /// Headers that will be added to request. |
| | 9494 | | /// </param> |
| | 9495 | | /// <param name='cancellationToken'> |
| | 9496 | | /// The cancellation token. |
| | 9497 | | /// </param> |
| | 9498 | | /// <exception cref="ErrorResponseException"> |
| | 9499 | | /// Thrown when the operation returned an invalid status code |
| | 9500 | | /// </exception> |
| | 9501 | | /// <exception cref="SerializationException"> |
| | 9502 | | /// Thrown when unable to deserialize the response |
| | 9503 | | /// </exception> |
| | 9504 | | /// <exception cref="ValidationException"> |
| | 9505 | | /// Thrown when a required parameter is null |
| | 9506 | | /// </exception> |
| | 9507 | | /// <exception cref="System.ArgumentNullException"> |
| | 9508 | | /// Thrown when a required parameter is null |
| | 9509 | | /// </exception> |
| | 9510 | | /// <return> |
| | 9511 | | /// A response object containing the response body and response headers. |
| | 9512 | | /// </return> |
| | 9513 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteCompositeEntityChildWithHttpMessagesAsync(System |
| | 9514 | | { |
| 0 | 9515 | | if (Client.Endpoint == null) |
| | 9516 | | { |
| 0 | 9517 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 9518 | | } |
| 0 | 9519 | | if (versionId == null) |
| | 9520 | | { |
| 0 | 9521 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 9522 | | } |
| | 9523 | | // Tracing |
| 0 | 9524 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 9525 | | string _invocationId = null; |
| 0 | 9526 | | if (_shouldTrace) |
| | 9527 | | { |
| 0 | 9528 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 9529 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 9530 | | tracingParameters.Add("appId", appId); |
| 0 | 9531 | | tracingParameters.Add("versionId", versionId); |
| 0 | 9532 | | tracingParameters.Add("cEntityId", cEntityId); |
| 0 | 9533 | | tracingParameters.Add("cChildId", cChildId); |
| 0 | 9534 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 9535 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteCompositeEntityChild", tracingParameters); |
| | 9536 | | } |
| | 9537 | | // Construct URL |
| 0 | 9538 | | var _baseUrl = Client.BaseUri; |
| 0 | 9539 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti |
| 0 | 9540 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 9541 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 9542 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 9543 | | _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| 0 | 9544 | | _url = _url.Replace("{cChildId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 9545 | | // Create HTTP transport objects |
| 0 | 9546 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 9547 | | HttpResponseMessage _httpResponse = null; |
| 0 | 9548 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 0 | 9549 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 9550 | | // Set Headers |
| | 9551 | |
|
| | 9552 | |
|
| 0 | 9553 | | if (customHeaders != null) |
| | 9554 | | { |
| 0 | 9555 | | foreach(var _header in customHeaders) |
| | 9556 | | { |
| 0 | 9557 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 9558 | | { |
| 0 | 9559 | | _httpRequest.Headers.Remove(_header.Key); |
| | 9560 | | } |
| 0 | 9561 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 9562 | | } |
| | 9563 | | } |
| | 9564 | |
|
| | 9565 | | // Serialize Request |
| 0 | 9566 | | string _requestContent = null; |
| | 9567 | | // Set Credentials |
| 0 | 9568 | | if (Client.Credentials != null) |
| | 9569 | | { |
| 0 | 9570 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 9571 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 9572 | | } |
| | 9573 | | // Send Request |
| 0 | 9574 | | if (_shouldTrace) |
| | 9575 | | { |
| 0 | 9576 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 9577 | | } |
| 0 | 9578 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 9579 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 9580 | | if (_shouldTrace) |
| | 9581 | | { |
| 0 | 9582 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 9583 | | } |
| 0 | 9584 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 9585 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 9586 | | string _responseContent = null; |
| 0 | 9587 | | if ((int)_statusCode != 200) |
| | 9588 | | { |
| 0 | 9589 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 9590 | | try |
| | 9591 | | { |
| 0 | 9592 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 9593 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 9594 | | if (_errorBody != null) |
| | 9595 | | { |
| 0 | 9596 | | ex.Body = _errorBody; |
| | 9597 | | } |
| 0 | 9598 | | } |
| 0 | 9599 | | catch (JsonException) |
| | 9600 | | { |
| | 9601 | | // Ignore the exception |
| 0 | 9602 | | } |
| 0 | 9603 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 9604 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 9605 | | if (_shouldTrace) |
| | 9606 | | { |
| 0 | 9607 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 9608 | | } |
| 0 | 9609 | | _httpRequest.Dispose(); |
| 0 | 9610 | | if (_httpResponse != null) |
| | 9611 | | { |
| 0 | 9612 | | _httpResponse.Dispose(); |
| | 9613 | | } |
| 0 | 9614 | | throw ex; |
| | 9615 | | } |
| | 9616 | | // Create Result |
| 0 | 9617 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 0 | 9618 | | _result.Request = _httpRequest; |
| 0 | 9619 | | _result.Response = _httpResponse; |
| | 9620 | | // Deserialize Response |
| 0 | 9621 | | if ((int)_statusCode == 200) |
| | 9622 | | { |
| 0 | 9623 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 9624 | | try |
| | 9625 | | { |
| 0 | 9626 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 0 | 9627 | | } |
| 0 | 9628 | | catch (JsonException ex) |
| | 9629 | | { |
| 0 | 9630 | | _httpRequest.Dispose(); |
| 0 | 9631 | | if (_httpResponse != null) |
| | 9632 | | { |
| 0 | 9633 | | _httpResponse.Dispose(); |
| | 9634 | | } |
| 0 | 9635 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 9636 | | } |
| | 9637 | | } |
| 0 | 9638 | | if (_shouldTrace) |
| | 9639 | | { |
| 0 | 9640 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 9641 | | } |
| 0 | 9642 | | return _result; |
| 0 | 9643 | | } |
| | 9644 | |
|
| | 9645 | | /// <summary> |
| | 9646 | | /// Gets information about the regular expression entity models in a version of |
| | 9647 | | /// the application. |
| | 9648 | | /// </summary> |
| | 9649 | | /// <param name='appId'> |
| | 9650 | | /// The application ID. |
| | 9651 | | /// </param> |
| | 9652 | | /// <param name='versionId'> |
| | 9653 | | /// The version ID. |
| | 9654 | | /// </param> |
| | 9655 | | /// <param name='skip'> |
| | 9656 | | /// The number of entries to skip. Default value is 0. |
| | 9657 | | /// </param> |
| | 9658 | | /// <param name='take'> |
| | 9659 | | /// The number of entries to return. Maximum page size is 500. Default is 100. |
| | 9660 | | /// </param> |
| | 9661 | | /// <param name='customHeaders'> |
| | 9662 | | /// Headers that will be added to request. |
| | 9663 | | /// </param> |
| | 9664 | | /// <param name='cancellationToken'> |
| | 9665 | | /// The cancellation token. |
| | 9666 | | /// </param> |
| | 9667 | | /// <exception cref="ErrorResponseException"> |
| | 9668 | | /// Thrown when the operation returned an invalid status code |
| | 9669 | | /// </exception> |
| | 9670 | | /// <exception cref="SerializationException"> |
| | 9671 | | /// Thrown when unable to deserialize the response |
| | 9672 | | /// </exception> |
| | 9673 | | /// <exception cref="ValidationException"> |
| | 9674 | | /// Thrown when a required parameter is null |
| | 9675 | | /// </exception> |
| | 9676 | | /// <exception cref="System.ArgumentNullException"> |
| | 9677 | | /// Thrown when a required parameter is null |
| | 9678 | | /// </exception> |
| | 9679 | | /// <return> |
| | 9680 | | /// A response object containing the response body and response headers. |
| | 9681 | | /// </return> |
| | 9682 | | public async Task<HttpOperationResponse<IList<RegexEntityExtractor>>> ListRegexEntityInfosWithHttpMessagesAsync( |
| | 9683 | | { |
| 2 | 9684 | | if (Client.Endpoint == null) |
| | 9685 | | { |
| 0 | 9686 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 9687 | | } |
| 2 | 9688 | | if (versionId == null) |
| | 9689 | | { |
| 0 | 9690 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 9691 | | } |
| 2 | 9692 | | if (skip < 0) |
| | 9693 | | { |
| 0 | 9694 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0); |
| | 9695 | | } |
| 2 | 9696 | | if (take > 500) |
| | 9697 | | { |
| 0 | 9698 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500); |
| | 9699 | | } |
| 2 | 9700 | | if (take < 0) |
| | 9701 | | { |
| 0 | 9702 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0); |
| | 9703 | | } |
| | 9704 | | // Tracing |
| 2 | 9705 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 9706 | | string _invocationId = null; |
| 2 | 9707 | | if (_shouldTrace) |
| | 9708 | | { |
| 0 | 9709 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 9710 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 9711 | | tracingParameters.Add("appId", appId); |
| 0 | 9712 | | tracingParameters.Add("versionId", versionId); |
| 0 | 9713 | | tracingParameters.Add("skip", skip); |
| 0 | 9714 | | tracingParameters.Add("take", take); |
| 0 | 9715 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 9716 | | ServiceClientTracing.Enter(_invocationId, this, "ListRegexEntityInfos", tracingParameters); |
| | 9717 | | } |
| | 9718 | | // Construct URL |
| 2 | 9719 | | var _baseUrl = Client.BaseUri; |
| 2 | 9720 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities |
| 2 | 9721 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 9722 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 9723 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 2 | 9724 | | List<string> _queryParameters = new List<string>(); |
| 2 | 9725 | | if (skip != null) |
| | 9726 | | { |
| 2 | 9727 | | _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 9728 | | } |
| 2 | 9729 | | if (take != null) |
| | 9730 | | { |
| 2 | 9731 | | _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 9732 | | } |
| 2 | 9733 | | if (_queryParameters.Count > 0) |
| | 9734 | | { |
| 2 | 9735 | | _url += "?" + string.Join("&", _queryParameters); |
| | 9736 | | } |
| | 9737 | | // Create HTTP transport objects |
| 2 | 9738 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 9739 | | HttpResponseMessage _httpResponse = null; |
| 2 | 9740 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 9741 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 9742 | | // Set Headers |
| | 9743 | |
|
| | 9744 | |
|
| 2 | 9745 | | if (customHeaders != null) |
| | 9746 | | { |
| 0 | 9747 | | foreach(var _header in customHeaders) |
| | 9748 | | { |
| 0 | 9749 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 9750 | | { |
| 0 | 9751 | | _httpRequest.Headers.Remove(_header.Key); |
| | 9752 | | } |
| 0 | 9753 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 9754 | | } |
| | 9755 | | } |
| | 9756 | |
|
| | 9757 | | // Serialize Request |
| 2 | 9758 | | string _requestContent = null; |
| | 9759 | | // Set Credentials |
| 2 | 9760 | | if (Client.Credentials != null) |
| | 9761 | | { |
| 2 | 9762 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 9763 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 9764 | | } |
| | 9765 | | // Send Request |
| 2 | 9766 | | if (_shouldTrace) |
| | 9767 | | { |
| 0 | 9768 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 9769 | | } |
| 2 | 9770 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 9771 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 9772 | | if (_shouldTrace) |
| | 9773 | | { |
| 0 | 9774 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 9775 | | } |
| 2 | 9776 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 9777 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 9778 | | string _responseContent = null; |
| 2 | 9779 | | if ((int)_statusCode != 200) |
| | 9780 | | { |
| 0 | 9781 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 9782 | | try |
| | 9783 | | { |
| 0 | 9784 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 9785 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 9786 | | if (_errorBody != null) |
| | 9787 | | { |
| 0 | 9788 | | ex.Body = _errorBody; |
| | 9789 | | } |
| 0 | 9790 | | } |
| 0 | 9791 | | catch (JsonException) |
| | 9792 | | { |
| | 9793 | | // Ignore the exception |
| 0 | 9794 | | } |
| 0 | 9795 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 9796 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 9797 | | if (_shouldTrace) |
| | 9798 | | { |
| 0 | 9799 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 9800 | | } |
| 0 | 9801 | | _httpRequest.Dispose(); |
| 0 | 9802 | | if (_httpResponse != null) |
| | 9803 | | { |
| 0 | 9804 | | _httpResponse.Dispose(); |
| | 9805 | | } |
| 0 | 9806 | | throw ex; |
| | 9807 | | } |
| | 9808 | | // Create Result |
| 2 | 9809 | | var _result = new HttpOperationResponse<IList<RegexEntityExtractor>>(); |
| 2 | 9810 | | _result.Request = _httpRequest; |
| 2 | 9811 | | _result.Response = _httpResponse; |
| | 9812 | | // Deserialize Response |
| 2 | 9813 | | if ((int)_statusCode == 200) |
| | 9814 | | { |
| 2 | 9815 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 9816 | | try |
| | 9817 | | { |
| 2 | 9818 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<RegexEntityExtractor>>(_re |
| 2 | 9819 | | } |
| 0 | 9820 | | catch (JsonException ex) |
| | 9821 | | { |
| 0 | 9822 | | _httpRequest.Dispose(); |
| 0 | 9823 | | if (_httpResponse != null) |
| | 9824 | | { |
| 0 | 9825 | | _httpResponse.Dispose(); |
| | 9826 | | } |
| 0 | 9827 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 9828 | | } |
| | 9829 | | } |
| 2 | 9830 | | if (_shouldTrace) |
| | 9831 | | { |
| 0 | 9832 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 9833 | | } |
| 2 | 9834 | | return _result; |
| 2 | 9835 | | } |
| | 9836 | |
|
| | 9837 | | /// <summary> |
| | 9838 | | /// Adds a regular expression entity model to a version of the application. |
| | 9839 | | /// </summary> |
| | 9840 | | /// <param name='appId'> |
| | 9841 | | /// The application ID. |
| | 9842 | | /// </param> |
| | 9843 | | /// <param name='versionId'> |
| | 9844 | | /// The version ID. |
| | 9845 | | /// </param> |
| | 9846 | | /// <param name='regexEntityExtractorCreateObj'> |
| | 9847 | | /// A model object containing the name and regex pattern for the new regular |
| | 9848 | | /// expression entity extractor. |
| | 9849 | | /// </param> |
| | 9850 | | /// <param name='customHeaders'> |
| | 9851 | | /// Headers that will be added to request. |
| | 9852 | | /// </param> |
| | 9853 | | /// <param name='cancellationToken'> |
| | 9854 | | /// The cancellation token. |
| | 9855 | | /// </param> |
| | 9856 | | /// <exception cref="ErrorResponseException"> |
| | 9857 | | /// Thrown when the operation returned an invalid status code |
| | 9858 | | /// </exception> |
| | 9859 | | /// <exception cref="SerializationException"> |
| | 9860 | | /// Thrown when unable to deserialize the response |
| | 9861 | | /// </exception> |
| | 9862 | | /// <exception cref="ValidationException"> |
| | 9863 | | /// Thrown when a required parameter is null |
| | 9864 | | /// </exception> |
| | 9865 | | /// <exception cref="System.ArgumentNullException"> |
| | 9866 | | /// Thrown when a required parameter is null |
| | 9867 | | /// </exception> |
| | 9868 | | /// <return> |
| | 9869 | | /// A response object containing the response body and response headers. |
| | 9870 | | /// </return> |
| | 9871 | | public async Task<HttpOperationResponse<System.Guid>> CreateRegexEntityModelWithHttpMessagesAsync(System.Guid ap |
| | 9872 | | { |
| 10 | 9873 | | if (Client.Endpoint == null) |
| | 9874 | | { |
| 0 | 9875 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 9876 | | } |
| 10 | 9877 | | if (versionId == null) |
| | 9878 | | { |
| 0 | 9879 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 9880 | | } |
| 10 | 9881 | | if (regexEntityExtractorCreateObj == null) |
| | 9882 | | { |
| 0 | 9883 | | throw new ValidationException(ValidationRules.CannotBeNull, "regexEntityExtractorCreateObj"); |
| | 9884 | | } |
| | 9885 | | // Tracing |
| 10 | 9886 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 10 | 9887 | | string _invocationId = null; |
| 10 | 9888 | | if (_shouldTrace) |
| | 9889 | | { |
| 0 | 9890 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 9891 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 9892 | | tracingParameters.Add("appId", appId); |
| 0 | 9893 | | tracingParameters.Add("versionId", versionId); |
| 0 | 9894 | | tracingParameters.Add("regexEntityExtractorCreateObj", regexEntityExtractorCreateObj); |
| 0 | 9895 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 9896 | | ServiceClientTracing.Enter(_invocationId, this, "CreateRegexEntityModel", tracingParameters); |
| | 9897 | | } |
| | 9898 | | // Construct URL |
| 10 | 9899 | | var _baseUrl = Client.BaseUri; |
| 10 | 9900 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities |
| 10 | 9901 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 10 | 9902 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 10 | 9903 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| | 9904 | | // Create HTTP transport objects |
| 10 | 9905 | | var _httpRequest = new HttpRequestMessage(); |
| 10 | 9906 | | HttpResponseMessage _httpResponse = null; |
| 10 | 9907 | | _httpRequest.Method = new HttpMethod("POST"); |
| 10 | 9908 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 9909 | | // Set Headers |
| | 9910 | |
|
| | 9911 | |
|
| 10 | 9912 | | if (customHeaders != null) |
| | 9913 | | { |
| 0 | 9914 | | foreach(var _header in customHeaders) |
| | 9915 | | { |
| 0 | 9916 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 9917 | | { |
| 0 | 9918 | | _httpRequest.Headers.Remove(_header.Key); |
| | 9919 | | } |
| 0 | 9920 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 9921 | | } |
| | 9922 | | } |
| | 9923 | |
|
| | 9924 | | // Serialize Request |
| 10 | 9925 | | string _requestContent = null; |
| 10 | 9926 | | if(regexEntityExtractorCreateObj != null) |
| | 9927 | | { |
| 10 | 9928 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(regexEntityExtractorCreateObj, Clie |
| 10 | 9929 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 10 | 9930 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 9931 | | } |
| | 9932 | | // Set Credentials |
| 10 | 9933 | | if (Client.Credentials != null) |
| | 9934 | | { |
| 10 | 9935 | | cancellationToken.ThrowIfCancellationRequested(); |
| 10 | 9936 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 9937 | | } |
| | 9938 | | // Send Request |
| 10 | 9939 | | if (_shouldTrace) |
| | 9940 | | { |
| 0 | 9941 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 9942 | | } |
| 10 | 9943 | | cancellationToken.ThrowIfCancellationRequested(); |
| 10 | 9944 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 10 | 9945 | | if (_shouldTrace) |
| | 9946 | | { |
| 0 | 9947 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 9948 | | } |
| 10 | 9949 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 10 | 9950 | | cancellationToken.ThrowIfCancellationRequested(); |
| 10 | 9951 | | string _responseContent = null; |
| 10 | 9952 | | if ((int)_statusCode != 201) |
| | 9953 | | { |
| 0 | 9954 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 9955 | | try |
| | 9956 | | { |
| 0 | 9957 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 9958 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 9959 | | if (_errorBody != null) |
| | 9960 | | { |
| 0 | 9961 | | ex.Body = _errorBody; |
| | 9962 | | } |
| 0 | 9963 | | } |
| 0 | 9964 | | catch (JsonException) |
| | 9965 | | { |
| | 9966 | | // Ignore the exception |
| 0 | 9967 | | } |
| 0 | 9968 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 9969 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 9970 | | if (_shouldTrace) |
| | 9971 | | { |
| 0 | 9972 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 9973 | | } |
| 0 | 9974 | | _httpRequest.Dispose(); |
| 0 | 9975 | | if (_httpResponse != null) |
| | 9976 | | { |
| 0 | 9977 | | _httpResponse.Dispose(); |
| | 9978 | | } |
| 0 | 9979 | | throw ex; |
| | 9980 | | } |
| | 9981 | | // Create Result |
| 10 | 9982 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 10 | 9983 | | _result.Request = _httpRequest; |
| 10 | 9984 | | _result.Response = _httpResponse; |
| | 9985 | | // Deserialize Response |
| 10 | 9986 | | if ((int)_statusCode == 201) |
| | 9987 | | { |
| 10 | 9988 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 9989 | | try |
| | 9990 | | { |
| 10 | 9991 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 10 | 9992 | | } |
| 0 | 9993 | | catch (JsonException ex) |
| | 9994 | | { |
| 0 | 9995 | | _httpRequest.Dispose(); |
| 0 | 9996 | | if (_httpResponse != null) |
| | 9997 | | { |
| 0 | 9998 | | _httpResponse.Dispose(); |
| | 9999 | | } |
| 0 | 10000 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 10001 | | } |
| | 10002 | | } |
| 10 | 10003 | | if (_shouldTrace) |
| | 10004 | | { |
| 0 | 10005 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 10006 | | } |
| 10 | 10007 | | return _result; |
| 10 | 10008 | | } |
| | 10009 | |
|
| | 10010 | | /// <summary> |
| | 10011 | | /// Get information about the Pattern.Any entity models in a version of the |
| | 10012 | | /// application. |
| | 10013 | | /// </summary> |
| | 10014 | | /// <param name='appId'> |
| | 10015 | | /// The application ID. |
| | 10016 | | /// </param> |
| | 10017 | | /// <param name='versionId'> |
| | 10018 | | /// The version ID. |
| | 10019 | | /// </param> |
| | 10020 | | /// <param name='skip'> |
| | 10021 | | /// The number of entries to skip. Default value is 0. |
| | 10022 | | /// </param> |
| | 10023 | | /// <param name='take'> |
| | 10024 | | /// The number of entries to return. Maximum page size is 500. Default is 100. |
| | 10025 | | /// </param> |
| | 10026 | | /// <param name='customHeaders'> |
| | 10027 | | /// Headers that will be added to request. |
| | 10028 | | /// </param> |
| | 10029 | | /// <param name='cancellationToken'> |
| | 10030 | | /// The cancellation token. |
| | 10031 | | /// </param> |
| | 10032 | | /// <exception cref="ErrorResponseException"> |
| | 10033 | | /// Thrown when the operation returned an invalid status code |
| | 10034 | | /// </exception> |
| | 10035 | | /// <exception cref="SerializationException"> |
| | 10036 | | /// Thrown when unable to deserialize the response |
| | 10037 | | /// </exception> |
| | 10038 | | /// <exception cref="ValidationException"> |
| | 10039 | | /// Thrown when a required parameter is null |
| | 10040 | | /// </exception> |
| | 10041 | | /// <exception cref="System.ArgumentNullException"> |
| | 10042 | | /// Thrown when a required parameter is null |
| | 10043 | | /// </exception> |
| | 10044 | | /// <return> |
| | 10045 | | /// A response object containing the response body and response headers. |
| | 10046 | | /// </return> |
| | 10047 | | public async Task<HttpOperationResponse<IList<PatternAnyEntityExtractor>>> ListPatternAnyEntityInfosWithHttpMess |
| | 10048 | | { |
| 2 | 10049 | | if (Client.Endpoint == null) |
| | 10050 | | { |
| 0 | 10051 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 10052 | | } |
| 2 | 10053 | | if (versionId == null) |
| | 10054 | | { |
| 0 | 10055 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 10056 | | } |
| 2 | 10057 | | if (skip < 0) |
| | 10058 | | { |
| 0 | 10059 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "skip", 0); |
| | 10060 | | } |
| 2 | 10061 | | if (take > 500) |
| | 10062 | | { |
| 0 | 10063 | | throw new ValidationException(ValidationRules.InclusiveMaximum, "take", 500); |
| | 10064 | | } |
| 2 | 10065 | | if (take < 0) |
| | 10066 | | { |
| 0 | 10067 | | throw new ValidationException(ValidationRules.InclusiveMinimum, "take", 0); |
| | 10068 | | } |
| | 10069 | | // Tracing |
| 2 | 10070 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 10071 | | string _invocationId = null; |
| 2 | 10072 | | if (_shouldTrace) |
| | 10073 | | { |
| 0 | 10074 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 10075 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 10076 | | tracingParameters.Add("appId", appId); |
| 0 | 10077 | | tracingParameters.Add("versionId", versionId); |
| 0 | 10078 | | tracingParameters.Add("skip", skip); |
| 0 | 10079 | | tracingParameters.Add("take", take); |
| 0 | 10080 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 10081 | | ServiceClientTracing.Enter(_invocationId, this, "ListPatternAnyEntityInfos", tracingParameters); |
| | 10082 | | } |
| | 10083 | | // Construct URL |
| 2 | 10084 | | var _baseUrl = Client.BaseUri; |
| 2 | 10085 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 2 | 10086 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 10087 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 10088 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 2 | 10089 | | List<string> _queryParameters = new List<string>(); |
| 2 | 10090 | | if (skip != null) |
| | 10091 | | { |
| 2 | 10092 | | _queryParameters.Add(string.Format("skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 10093 | | } |
| 2 | 10094 | | if (take != null) |
| | 10095 | | { |
| 2 | 10096 | | _queryParameters.Add(string.Format("take={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonCo |
| | 10097 | | } |
| 2 | 10098 | | if (_queryParameters.Count > 0) |
| | 10099 | | { |
| 2 | 10100 | | _url += "?" + string.Join("&", _queryParameters); |
| | 10101 | | } |
| | 10102 | | // Create HTTP transport objects |
| 2 | 10103 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 10104 | | HttpResponseMessage _httpResponse = null; |
| 2 | 10105 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 10106 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 10107 | | // Set Headers |
| | 10108 | |
|
| | 10109 | |
|
| 2 | 10110 | | if (customHeaders != null) |
| | 10111 | | { |
| 0 | 10112 | | foreach(var _header in customHeaders) |
| | 10113 | | { |
| 0 | 10114 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 10115 | | { |
| 0 | 10116 | | _httpRequest.Headers.Remove(_header.Key); |
| | 10117 | | } |
| 0 | 10118 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 10119 | | } |
| | 10120 | | } |
| | 10121 | |
|
| | 10122 | | // Serialize Request |
| 2 | 10123 | | string _requestContent = null; |
| | 10124 | | // Set Credentials |
| 2 | 10125 | | if (Client.Credentials != null) |
| | 10126 | | { |
| 2 | 10127 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 10128 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 10129 | | } |
| | 10130 | | // Send Request |
| 2 | 10131 | | if (_shouldTrace) |
| | 10132 | | { |
| 0 | 10133 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 10134 | | } |
| 2 | 10135 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 10136 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 10137 | | if (_shouldTrace) |
| | 10138 | | { |
| 0 | 10139 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 10140 | | } |
| 2 | 10141 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 10142 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 10143 | | string _responseContent = null; |
| 2 | 10144 | | if ((int)_statusCode != 200) |
| | 10145 | | { |
| 0 | 10146 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 10147 | | try |
| | 10148 | | { |
| 0 | 10149 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 10150 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 10151 | | if (_errorBody != null) |
| | 10152 | | { |
| 0 | 10153 | | ex.Body = _errorBody; |
| | 10154 | | } |
| 0 | 10155 | | } |
| 0 | 10156 | | catch (JsonException) |
| | 10157 | | { |
| | 10158 | | // Ignore the exception |
| 0 | 10159 | | } |
| 0 | 10160 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 10161 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 10162 | | if (_shouldTrace) |
| | 10163 | | { |
| 0 | 10164 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 10165 | | } |
| 0 | 10166 | | _httpRequest.Dispose(); |
| 0 | 10167 | | if (_httpResponse != null) |
| | 10168 | | { |
| 0 | 10169 | | _httpResponse.Dispose(); |
| | 10170 | | } |
| 0 | 10171 | | throw ex; |
| | 10172 | | } |
| | 10173 | | // Create Result |
| 2 | 10174 | | var _result = new HttpOperationResponse<IList<PatternAnyEntityExtractor>>(); |
| 2 | 10175 | | _result.Request = _httpRequest; |
| 2 | 10176 | | _result.Response = _httpResponse; |
| | 10177 | | // Deserialize Response |
| 2 | 10178 | | if ((int)_statusCode == 200) |
| | 10179 | | { |
| 2 | 10180 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 10181 | | try |
| | 10182 | | { |
| 2 | 10183 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<PatternAnyEntityExtractor> |
| 2 | 10184 | | } |
| 0 | 10185 | | catch (JsonException ex) |
| | 10186 | | { |
| 0 | 10187 | | _httpRequest.Dispose(); |
| 0 | 10188 | | if (_httpResponse != null) |
| | 10189 | | { |
| 0 | 10190 | | _httpResponse.Dispose(); |
| | 10191 | | } |
| 0 | 10192 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 10193 | | } |
| | 10194 | | } |
| 2 | 10195 | | if (_shouldTrace) |
| | 10196 | | { |
| 0 | 10197 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 10198 | | } |
| 2 | 10199 | | return _result; |
| 2 | 10200 | | } |
| | 10201 | |
|
| | 10202 | | /// <summary> |
| | 10203 | | /// Adds a pattern.any entity extractor to a version of the application. |
| | 10204 | | /// </summary> |
| | 10205 | | /// <param name='appId'> |
| | 10206 | | /// The application ID. |
| | 10207 | | /// </param> |
| | 10208 | | /// <param name='versionId'> |
| | 10209 | | /// The version ID. |
| | 10210 | | /// </param> |
| | 10211 | | /// <param name='extractorCreateObject'> |
| | 10212 | | /// A model object containing the name and explicit list for the new |
| | 10213 | | /// Pattern.Any entity extractor. |
| | 10214 | | /// </param> |
| | 10215 | | /// <param name='customHeaders'> |
| | 10216 | | /// Headers that will be added to request. |
| | 10217 | | /// </param> |
| | 10218 | | /// <param name='cancellationToken'> |
| | 10219 | | /// The cancellation token. |
| | 10220 | | /// </param> |
| | 10221 | | /// <exception cref="ErrorResponseException"> |
| | 10222 | | /// Thrown when the operation returned an invalid status code |
| | 10223 | | /// </exception> |
| | 10224 | | /// <exception cref="SerializationException"> |
| | 10225 | | /// Thrown when unable to deserialize the response |
| | 10226 | | /// </exception> |
| | 10227 | | /// <exception cref="ValidationException"> |
| | 10228 | | /// Thrown when a required parameter is null |
| | 10229 | | /// </exception> |
| | 10230 | | /// <exception cref="System.ArgumentNullException"> |
| | 10231 | | /// Thrown when a required parameter is null |
| | 10232 | | /// </exception> |
| | 10233 | | /// <return> |
| | 10234 | | /// A response object containing the response body and response headers. |
| | 10235 | | /// </return> |
| | 10236 | | public async Task<HttpOperationResponse<System.Guid>> CreatePatternAnyEntityModelWithHttpMessagesAsync(System.Gu |
| | 10237 | | { |
| 15 | 10238 | | if (Client.Endpoint == null) |
| | 10239 | | { |
| 0 | 10240 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 10241 | | } |
| 15 | 10242 | | if (versionId == null) |
| | 10243 | | { |
| 0 | 10244 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 10245 | | } |
| 15 | 10246 | | if (extractorCreateObject == null) |
| | 10247 | | { |
| 0 | 10248 | | throw new ValidationException(ValidationRules.CannotBeNull, "extractorCreateObject"); |
| | 10249 | | } |
| | 10250 | | // Tracing |
| 15 | 10251 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 15 | 10252 | | string _invocationId = null; |
| 15 | 10253 | | if (_shouldTrace) |
| | 10254 | | { |
| 0 | 10255 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 10256 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 10257 | | tracingParameters.Add("appId", appId); |
| 0 | 10258 | | tracingParameters.Add("versionId", versionId); |
| 0 | 10259 | | tracingParameters.Add("extractorCreateObject", extractorCreateObject); |
| 0 | 10260 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 10261 | | ServiceClientTracing.Enter(_invocationId, this, "CreatePatternAnyEntityModel", tracingParameters); |
| | 10262 | | } |
| | 10263 | | // Construct URL |
| 15 | 10264 | | var _baseUrl = Client.BaseUri; |
| 15 | 10265 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 15 | 10266 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 15 | 10267 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 15 | 10268 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| | 10269 | | // Create HTTP transport objects |
| 15 | 10270 | | var _httpRequest = new HttpRequestMessage(); |
| 15 | 10271 | | HttpResponseMessage _httpResponse = null; |
| 15 | 10272 | | _httpRequest.Method = new HttpMethod("POST"); |
| 15 | 10273 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 10274 | | // Set Headers |
| | 10275 | |
|
| | 10276 | |
|
| 15 | 10277 | | if (customHeaders != null) |
| | 10278 | | { |
| 0 | 10279 | | foreach(var _header in customHeaders) |
| | 10280 | | { |
| 0 | 10281 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 10282 | | { |
| 0 | 10283 | | _httpRequest.Headers.Remove(_header.Key); |
| | 10284 | | } |
| 0 | 10285 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 10286 | | } |
| | 10287 | | } |
| | 10288 | |
|
| | 10289 | | // Serialize Request |
| 15 | 10290 | | string _requestContent = null; |
| 15 | 10291 | | if(extractorCreateObject != null) |
| | 10292 | | { |
| 15 | 10293 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(extractorCreateObject, Client.Seria |
| 15 | 10294 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 15 | 10295 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 10296 | | } |
| | 10297 | | // Set Credentials |
| 15 | 10298 | | if (Client.Credentials != null) |
| | 10299 | | { |
| 15 | 10300 | | cancellationToken.ThrowIfCancellationRequested(); |
| 15 | 10301 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 10302 | | } |
| | 10303 | | // Send Request |
| 15 | 10304 | | if (_shouldTrace) |
| | 10305 | | { |
| 0 | 10306 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 10307 | | } |
| 15 | 10308 | | cancellationToken.ThrowIfCancellationRequested(); |
| 15 | 10309 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 15 | 10310 | | if (_shouldTrace) |
| | 10311 | | { |
| 0 | 10312 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 10313 | | } |
| 15 | 10314 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 15 | 10315 | | cancellationToken.ThrowIfCancellationRequested(); |
| 15 | 10316 | | string _responseContent = null; |
| 15 | 10317 | | if ((int)_statusCode != 201) |
| | 10318 | | { |
| 0 | 10319 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 10320 | | try |
| | 10321 | | { |
| 0 | 10322 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 10323 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 10324 | | if (_errorBody != null) |
| | 10325 | | { |
| 0 | 10326 | | ex.Body = _errorBody; |
| | 10327 | | } |
| 0 | 10328 | | } |
| 0 | 10329 | | catch (JsonException) |
| | 10330 | | { |
| | 10331 | | // Ignore the exception |
| 0 | 10332 | | } |
| 0 | 10333 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 10334 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 10335 | | if (_shouldTrace) |
| | 10336 | | { |
| 0 | 10337 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 10338 | | } |
| 0 | 10339 | | _httpRequest.Dispose(); |
| 0 | 10340 | | if (_httpResponse != null) |
| | 10341 | | { |
| 0 | 10342 | | _httpResponse.Dispose(); |
| | 10343 | | } |
| 0 | 10344 | | throw ex; |
| | 10345 | | } |
| | 10346 | | // Create Result |
| 15 | 10347 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 15 | 10348 | | _result.Request = _httpRequest; |
| 15 | 10349 | | _result.Response = _httpResponse; |
| | 10350 | | // Deserialize Response |
| 15 | 10351 | | if ((int)_statusCode == 201) |
| | 10352 | | { |
| 15 | 10353 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 10354 | | try |
| | 10355 | | { |
| 15 | 10356 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 15 | 10357 | | } |
| 0 | 10358 | | catch (JsonException ex) |
| | 10359 | | { |
| 0 | 10360 | | _httpRequest.Dispose(); |
| 0 | 10361 | | if (_httpResponse != null) |
| | 10362 | | { |
| 0 | 10363 | | _httpResponse.Dispose(); |
| | 10364 | | } |
| 0 | 10365 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 10366 | | } |
| | 10367 | | } |
| 15 | 10368 | | if (_shouldTrace) |
| | 10369 | | { |
| 0 | 10370 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 10371 | | } |
| 15 | 10372 | | return _result; |
| 15 | 10373 | | } |
| | 10374 | |
|
| | 10375 | | /// <summary> |
| | 10376 | | /// Get all roles for an entity in a version of the application |
| | 10377 | | /// </summary> |
| | 10378 | | /// <param name='appId'> |
| | 10379 | | /// The application ID. |
| | 10380 | | /// </param> |
| | 10381 | | /// <param name='versionId'> |
| | 10382 | | /// The version ID. |
| | 10383 | | /// </param> |
| | 10384 | | /// <param name='entityId'> |
| | 10385 | | /// entity Id |
| | 10386 | | /// </param> |
| | 10387 | | /// <param name='customHeaders'> |
| | 10388 | | /// Headers that will be added to request. |
| | 10389 | | /// </param> |
| | 10390 | | /// <param name='cancellationToken'> |
| | 10391 | | /// The cancellation token. |
| | 10392 | | /// </param> |
| | 10393 | | /// <exception cref="ErrorResponseException"> |
| | 10394 | | /// Thrown when the operation returned an invalid status code |
| | 10395 | | /// </exception> |
| | 10396 | | /// <exception cref="SerializationException"> |
| | 10397 | | /// Thrown when unable to deserialize the response |
| | 10398 | | /// </exception> |
| | 10399 | | /// <exception cref="ValidationException"> |
| | 10400 | | /// Thrown when a required parameter is null |
| | 10401 | | /// </exception> |
| | 10402 | | /// <exception cref="System.ArgumentNullException"> |
| | 10403 | | /// Thrown when a required parameter is null |
| | 10404 | | /// </exception> |
| | 10405 | | /// <return> |
| | 10406 | | /// A response object containing the response body and response headers. |
| | 10407 | | /// </return> |
| | 10408 | | public async Task<HttpOperationResponse<IList<EntityRole>>> ListEntityRolesWithHttpMessagesAsync(System.Guid app |
| | 10409 | | { |
| 3 | 10410 | | if (Client.Endpoint == null) |
| | 10411 | | { |
| 0 | 10412 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 10413 | | } |
| 3 | 10414 | | if (versionId == null) |
| | 10415 | | { |
| 0 | 10416 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 10417 | | } |
| | 10418 | | // Tracing |
| 3 | 10419 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 3 | 10420 | | string _invocationId = null; |
| 3 | 10421 | | if (_shouldTrace) |
| | 10422 | | { |
| 0 | 10423 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 10424 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 10425 | | tracingParameters.Add("appId", appId); |
| 0 | 10426 | | tracingParameters.Add("versionId", versionId); |
| 0 | 10427 | | tracingParameters.Add("entityId", entityId); |
| 0 | 10428 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 10429 | | ServiceClientTracing.Enter(_invocationId, this, "ListEntityRoles", tracingParameters); |
| | 10430 | | } |
| | 10431 | | // Construct URL |
| 3 | 10432 | | var _baseUrl = Client.BaseUri; |
| 3 | 10433 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent |
| 3 | 10434 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 3 | 10435 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 3 | 10436 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 3 | 10437 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 10438 | | // Create HTTP transport objects |
| 3 | 10439 | | var _httpRequest = new HttpRequestMessage(); |
| 3 | 10440 | | HttpResponseMessage _httpResponse = null; |
| 3 | 10441 | | _httpRequest.Method = new HttpMethod("GET"); |
| 3 | 10442 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 10443 | | // Set Headers |
| | 10444 | |
|
| | 10445 | |
|
| 3 | 10446 | | if (customHeaders != null) |
| | 10447 | | { |
| 0 | 10448 | | foreach(var _header in customHeaders) |
| | 10449 | | { |
| 0 | 10450 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 10451 | | { |
| 0 | 10452 | | _httpRequest.Headers.Remove(_header.Key); |
| | 10453 | | } |
| 0 | 10454 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 10455 | | } |
| | 10456 | | } |
| | 10457 | |
|
| | 10458 | | // Serialize Request |
| 3 | 10459 | | string _requestContent = null; |
| | 10460 | | // Set Credentials |
| 3 | 10461 | | if (Client.Credentials != null) |
| | 10462 | | { |
| 3 | 10463 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 10464 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 10465 | | } |
| | 10466 | | // Send Request |
| 3 | 10467 | | if (_shouldTrace) |
| | 10468 | | { |
| 0 | 10469 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 10470 | | } |
| 3 | 10471 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 10472 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 3 | 10473 | | if (_shouldTrace) |
| | 10474 | | { |
| 0 | 10475 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 10476 | | } |
| 3 | 10477 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 3 | 10478 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 10479 | | string _responseContent = null; |
| 3 | 10480 | | if ((int)_statusCode != 200) |
| | 10481 | | { |
| 0 | 10482 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 10483 | | try |
| | 10484 | | { |
| 0 | 10485 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 10486 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 10487 | | if (_errorBody != null) |
| | 10488 | | { |
| 0 | 10489 | | ex.Body = _errorBody; |
| | 10490 | | } |
| 0 | 10491 | | } |
| 0 | 10492 | | catch (JsonException) |
| | 10493 | | { |
| | 10494 | | // Ignore the exception |
| 0 | 10495 | | } |
| 0 | 10496 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 10497 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 10498 | | if (_shouldTrace) |
| | 10499 | | { |
| 0 | 10500 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 10501 | | } |
| 0 | 10502 | | _httpRequest.Dispose(); |
| 0 | 10503 | | if (_httpResponse != null) |
| | 10504 | | { |
| 0 | 10505 | | _httpResponse.Dispose(); |
| | 10506 | | } |
| 0 | 10507 | | throw ex; |
| | 10508 | | } |
| | 10509 | | // Create Result |
| 3 | 10510 | | var _result = new HttpOperationResponse<IList<EntityRole>>(); |
| 3 | 10511 | | _result.Request = _httpRequest; |
| 3 | 10512 | | _result.Response = _httpResponse; |
| | 10513 | | // Deserialize Response |
| 3 | 10514 | | if ((int)_statusCode == 200) |
| | 10515 | | { |
| 3 | 10516 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 10517 | | try |
| | 10518 | | { |
| 3 | 10519 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont |
| 3 | 10520 | | } |
| 0 | 10521 | | catch (JsonException ex) |
| | 10522 | | { |
| 0 | 10523 | | _httpRequest.Dispose(); |
| 0 | 10524 | | if (_httpResponse != null) |
| | 10525 | | { |
| 0 | 10526 | | _httpResponse.Dispose(); |
| | 10527 | | } |
| 0 | 10528 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 10529 | | } |
| | 10530 | | } |
| 3 | 10531 | | if (_shouldTrace) |
| | 10532 | | { |
| 0 | 10533 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 10534 | | } |
| 3 | 10535 | | return _result; |
| 3 | 10536 | | } |
| | 10537 | |
|
| | 10538 | | /// <summary> |
| | 10539 | | /// Create an entity role in a version of the application. |
| | 10540 | | /// </summary> |
| | 10541 | | /// <param name='appId'> |
| | 10542 | | /// The application ID. |
| | 10543 | | /// </param> |
| | 10544 | | /// <param name='versionId'> |
| | 10545 | | /// The version ID. |
| | 10546 | | /// </param> |
| | 10547 | | /// <param name='entityId'> |
| | 10548 | | /// The entity model ID. |
| | 10549 | | /// </param> |
| | 10550 | | /// <param name='entityRoleCreateObject'> |
| | 10551 | | /// An entity role object containing the name of role. |
| | 10552 | | /// </param> |
| | 10553 | | /// <param name='customHeaders'> |
| | 10554 | | /// Headers that will be added to request. |
| | 10555 | | /// </param> |
| | 10556 | | /// <param name='cancellationToken'> |
| | 10557 | | /// The cancellation token. |
| | 10558 | | /// </param> |
| | 10559 | | /// <exception cref="ErrorResponseException"> |
| | 10560 | | /// Thrown when the operation returned an invalid status code |
| | 10561 | | /// </exception> |
| | 10562 | | /// <exception cref="SerializationException"> |
| | 10563 | | /// Thrown when unable to deserialize the response |
| | 10564 | | /// </exception> |
| | 10565 | | /// <exception cref="ValidationException"> |
| | 10566 | | /// Thrown when a required parameter is null |
| | 10567 | | /// </exception> |
| | 10568 | | /// <exception cref="System.ArgumentNullException"> |
| | 10569 | | /// Thrown when a required parameter is null |
| | 10570 | | /// </exception> |
| | 10571 | | /// <return> |
| | 10572 | | /// A response object containing the response body and response headers. |
| | 10573 | | /// </return> |
| | 10574 | | public async Task<HttpOperationResponse<System.Guid>> CreateEntityRoleWithHttpMessagesAsync(System.Guid appId, s |
| | 10575 | | { |
| 5 | 10576 | | if (Client.Endpoint == null) |
| | 10577 | | { |
| 0 | 10578 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 10579 | | } |
| 5 | 10580 | | if (versionId == null) |
| | 10581 | | { |
| 0 | 10582 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 10583 | | } |
| 5 | 10584 | | if (entityRoleCreateObject == null) |
| | 10585 | | { |
| 0 | 10586 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject"); |
| | 10587 | | } |
| | 10588 | | // Tracing |
| 5 | 10589 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 5 | 10590 | | string _invocationId = null; |
| 5 | 10591 | | if (_shouldTrace) |
| | 10592 | | { |
| 0 | 10593 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 10594 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 10595 | | tracingParameters.Add("appId", appId); |
| 0 | 10596 | | tracingParameters.Add("versionId", versionId); |
| 0 | 10597 | | tracingParameters.Add("entityId", entityId); |
| 0 | 10598 | | tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject); |
| 0 | 10599 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 10600 | | ServiceClientTracing.Enter(_invocationId, this, "CreateEntityRole", tracingParameters); |
| | 10601 | | } |
| | 10602 | | // Construct URL |
| 5 | 10603 | | var _baseUrl = Client.BaseUri; |
| 5 | 10604 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent |
| 5 | 10605 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 5 | 10606 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 5 | 10607 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 5 | 10608 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 10609 | | // Create HTTP transport objects |
| 5 | 10610 | | var _httpRequest = new HttpRequestMessage(); |
| 5 | 10611 | | HttpResponseMessage _httpResponse = null; |
| 5 | 10612 | | _httpRequest.Method = new HttpMethod("POST"); |
| 5 | 10613 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 10614 | | // Set Headers |
| | 10615 | |
|
| | 10616 | |
|
| 5 | 10617 | | if (customHeaders != null) |
| | 10618 | | { |
| 0 | 10619 | | foreach(var _header in customHeaders) |
| | 10620 | | { |
| 0 | 10621 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 10622 | | { |
| 0 | 10623 | | _httpRequest.Headers.Remove(_header.Key); |
| | 10624 | | } |
| 0 | 10625 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 10626 | | } |
| | 10627 | | } |
| | 10628 | |
|
| | 10629 | | // Serialize Request |
| 5 | 10630 | | string _requestContent = null; |
| 5 | 10631 | | if(entityRoleCreateObject != null) |
| | 10632 | | { |
| 5 | 10633 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri |
| 5 | 10634 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 5 | 10635 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 10636 | | } |
| | 10637 | | // Set Credentials |
| 5 | 10638 | | if (Client.Credentials != null) |
| | 10639 | | { |
| 5 | 10640 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 10641 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 10642 | | } |
| | 10643 | | // Send Request |
| 5 | 10644 | | if (_shouldTrace) |
| | 10645 | | { |
| 0 | 10646 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 10647 | | } |
| 5 | 10648 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 10649 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 5 | 10650 | | if (_shouldTrace) |
| | 10651 | | { |
| 0 | 10652 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 10653 | | } |
| 5 | 10654 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 5 | 10655 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 10656 | | string _responseContent = null; |
| 5 | 10657 | | if ((int)_statusCode != 201) |
| | 10658 | | { |
| 0 | 10659 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 10660 | | try |
| | 10661 | | { |
| 0 | 10662 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 10663 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 10664 | | if (_errorBody != null) |
| | 10665 | | { |
| 0 | 10666 | | ex.Body = _errorBody; |
| | 10667 | | } |
| 0 | 10668 | | } |
| 0 | 10669 | | catch (JsonException) |
| | 10670 | | { |
| | 10671 | | // Ignore the exception |
| 0 | 10672 | | } |
| 0 | 10673 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 10674 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 10675 | | if (_shouldTrace) |
| | 10676 | | { |
| 0 | 10677 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 10678 | | } |
| 0 | 10679 | | _httpRequest.Dispose(); |
| 0 | 10680 | | if (_httpResponse != null) |
| | 10681 | | { |
| 0 | 10682 | | _httpResponse.Dispose(); |
| | 10683 | | } |
| 0 | 10684 | | throw ex; |
| | 10685 | | } |
| | 10686 | | // Create Result |
| 5 | 10687 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 5 | 10688 | | _result.Request = _httpRequest; |
| 5 | 10689 | | _result.Response = _httpResponse; |
| | 10690 | | // Deserialize Response |
| 5 | 10691 | | if ((int)_statusCode == 201) |
| | 10692 | | { |
| 5 | 10693 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 10694 | | try |
| | 10695 | | { |
| 5 | 10696 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 5 | 10697 | | } |
| 0 | 10698 | | catch (JsonException ex) |
| | 10699 | | { |
| 0 | 10700 | | _httpRequest.Dispose(); |
| 0 | 10701 | | if (_httpResponse != null) |
| | 10702 | | { |
| 0 | 10703 | | _httpResponse.Dispose(); |
| | 10704 | | } |
| 0 | 10705 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 10706 | | } |
| | 10707 | | } |
| 5 | 10708 | | if (_shouldTrace) |
| | 10709 | | { |
| 0 | 10710 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 10711 | | } |
| 5 | 10712 | | return _result; |
| 5 | 10713 | | } |
| | 10714 | |
|
| | 10715 | | /// <summary> |
| | 10716 | | /// Get a prebuilt entity's roles in a version of the application. |
| | 10717 | | /// </summary> |
| | 10718 | | /// <param name='appId'> |
| | 10719 | | /// The application ID. |
| | 10720 | | /// </param> |
| | 10721 | | /// <param name='versionId'> |
| | 10722 | | /// The version ID. |
| | 10723 | | /// </param> |
| | 10724 | | /// <param name='entityId'> |
| | 10725 | | /// entity Id |
| | 10726 | | /// </param> |
| | 10727 | | /// <param name='customHeaders'> |
| | 10728 | | /// Headers that will be added to request. |
| | 10729 | | /// </param> |
| | 10730 | | /// <param name='cancellationToken'> |
| | 10731 | | /// The cancellation token. |
| | 10732 | | /// </param> |
| | 10733 | | /// <exception cref="ErrorResponseException"> |
| | 10734 | | /// Thrown when the operation returned an invalid status code |
| | 10735 | | /// </exception> |
| | 10736 | | /// <exception cref="SerializationException"> |
| | 10737 | | /// Thrown when unable to deserialize the response |
| | 10738 | | /// </exception> |
| | 10739 | | /// <exception cref="ValidationException"> |
| | 10740 | | /// Thrown when a required parameter is null |
| | 10741 | | /// </exception> |
| | 10742 | | /// <exception cref="System.ArgumentNullException"> |
| | 10743 | | /// Thrown when a required parameter is null |
| | 10744 | | /// </exception> |
| | 10745 | | /// <return> |
| | 10746 | | /// A response object containing the response body and response headers. |
| | 10747 | | /// </return> |
| | 10748 | | public async Task<HttpOperationResponse<IList<EntityRole>>> ListPrebuiltEntityRolesWithHttpMessagesAsync(System. |
| | 10749 | | { |
| 3 | 10750 | | if (Client.Endpoint == null) |
| | 10751 | | { |
| 0 | 10752 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 10753 | | } |
| 3 | 10754 | | if (versionId == null) |
| | 10755 | | { |
| 0 | 10756 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 10757 | | } |
| | 10758 | | // Tracing |
| 3 | 10759 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 3 | 10760 | | string _invocationId = null; |
| 3 | 10761 | | if (_shouldTrace) |
| | 10762 | | { |
| 0 | 10763 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 10764 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 10765 | | tracingParameters.Add("appId", appId); |
| 0 | 10766 | | tracingParameters.Add("versionId", versionId); |
| 0 | 10767 | | tracingParameters.Add("entityId", entityId); |
| 0 | 10768 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 10769 | | ServiceClientTracing.Enter(_invocationId, this, "ListPrebuiltEntityRoles", tracingParameters); |
| | 10770 | | } |
| | 10771 | | // Construct URL |
| 3 | 10772 | | var _baseUrl = Client.BaseUri; |
| 3 | 10773 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts/{en |
| 3 | 10774 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 3 | 10775 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 3 | 10776 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 3 | 10777 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 10778 | | // Create HTTP transport objects |
| 3 | 10779 | | var _httpRequest = new HttpRequestMessage(); |
| 3 | 10780 | | HttpResponseMessage _httpResponse = null; |
| 3 | 10781 | | _httpRequest.Method = new HttpMethod("GET"); |
| 3 | 10782 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 10783 | | // Set Headers |
| | 10784 | |
|
| | 10785 | |
|
| 3 | 10786 | | if (customHeaders != null) |
| | 10787 | | { |
| 0 | 10788 | | foreach(var _header in customHeaders) |
| | 10789 | | { |
| 0 | 10790 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 10791 | | { |
| 0 | 10792 | | _httpRequest.Headers.Remove(_header.Key); |
| | 10793 | | } |
| 0 | 10794 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 10795 | | } |
| | 10796 | | } |
| | 10797 | |
|
| | 10798 | | // Serialize Request |
| 3 | 10799 | | string _requestContent = null; |
| | 10800 | | // Set Credentials |
| 3 | 10801 | | if (Client.Credentials != null) |
| | 10802 | | { |
| 3 | 10803 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 10804 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 10805 | | } |
| | 10806 | | // Send Request |
| 3 | 10807 | | if (_shouldTrace) |
| | 10808 | | { |
| 0 | 10809 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 10810 | | } |
| 3 | 10811 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 10812 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 3 | 10813 | | if (_shouldTrace) |
| | 10814 | | { |
| 0 | 10815 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 10816 | | } |
| 3 | 10817 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 3 | 10818 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 10819 | | string _responseContent = null; |
| 3 | 10820 | | if ((int)_statusCode != 200) |
| | 10821 | | { |
| 0 | 10822 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 10823 | | try |
| | 10824 | | { |
| 0 | 10825 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 10826 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 10827 | | if (_errorBody != null) |
| | 10828 | | { |
| 0 | 10829 | | ex.Body = _errorBody; |
| | 10830 | | } |
| 0 | 10831 | | } |
| 0 | 10832 | | catch (JsonException) |
| | 10833 | | { |
| | 10834 | | // Ignore the exception |
| 0 | 10835 | | } |
| 0 | 10836 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 10837 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 10838 | | if (_shouldTrace) |
| | 10839 | | { |
| 0 | 10840 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 10841 | | } |
| 0 | 10842 | | _httpRequest.Dispose(); |
| 0 | 10843 | | if (_httpResponse != null) |
| | 10844 | | { |
| 0 | 10845 | | _httpResponse.Dispose(); |
| | 10846 | | } |
| 0 | 10847 | | throw ex; |
| | 10848 | | } |
| | 10849 | | // Create Result |
| 3 | 10850 | | var _result = new HttpOperationResponse<IList<EntityRole>>(); |
| 3 | 10851 | | _result.Request = _httpRequest; |
| 3 | 10852 | | _result.Response = _httpResponse; |
| | 10853 | | // Deserialize Response |
| 3 | 10854 | | if ((int)_statusCode == 200) |
| | 10855 | | { |
| 3 | 10856 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 10857 | | try |
| | 10858 | | { |
| 3 | 10859 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont |
| 3 | 10860 | | } |
| 0 | 10861 | | catch (JsonException ex) |
| | 10862 | | { |
| 0 | 10863 | | _httpRequest.Dispose(); |
| 0 | 10864 | | if (_httpResponse != null) |
| | 10865 | | { |
| 0 | 10866 | | _httpResponse.Dispose(); |
| | 10867 | | } |
| 0 | 10868 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 10869 | | } |
| | 10870 | | } |
| 3 | 10871 | | if (_shouldTrace) |
| | 10872 | | { |
| 0 | 10873 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 10874 | | } |
| 3 | 10875 | | return _result; |
| 3 | 10876 | | } |
| | 10877 | |
|
| | 10878 | | /// <summary> |
| | 10879 | | /// Create a role for a prebuilt entity in a version of the application. |
| | 10880 | | /// </summary> |
| | 10881 | | /// <param name='appId'> |
| | 10882 | | /// The application ID. |
| | 10883 | | /// </param> |
| | 10884 | | /// <param name='versionId'> |
| | 10885 | | /// The version ID. |
| | 10886 | | /// </param> |
| | 10887 | | /// <param name='entityId'> |
| | 10888 | | /// The entity model ID. |
| | 10889 | | /// </param> |
| | 10890 | | /// <param name='entityRoleCreateObject'> |
| | 10891 | | /// An entity role object containing the name of role. |
| | 10892 | | /// </param> |
| | 10893 | | /// <param name='customHeaders'> |
| | 10894 | | /// Headers that will be added to request. |
| | 10895 | | /// </param> |
| | 10896 | | /// <param name='cancellationToken'> |
| | 10897 | | /// The cancellation token. |
| | 10898 | | /// </param> |
| | 10899 | | /// <exception cref="ErrorResponseException"> |
| | 10900 | | /// Thrown when the operation returned an invalid status code |
| | 10901 | | /// </exception> |
| | 10902 | | /// <exception cref="SerializationException"> |
| | 10903 | | /// Thrown when unable to deserialize the response |
| | 10904 | | /// </exception> |
| | 10905 | | /// <exception cref="ValidationException"> |
| | 10906 | | /// Thrown when a required parameter is null |
| | 10907 | | /// </exception> |
| | 10908 | | /// <exception cref="System.ArgumentNullException"> |
| | 10909 | | /// Thrown when a required parameter is null |
| | 10910 | | /// </exception> |
| | 10911 | | /// <return> |
| | 10912 | | /// A response object containing the response body and response headers. |
| | 10913 | | /// </return> |
| | 10914 | | public async Task<HttpOperationResponse<System.Guid>> CreatePrebuiltEntityRoleWithHttpMessagesAsync(System.Guid |
| | 10915 | | { |
| 5 | 10916 | | if (Client.Endpoint == null) |
| | 10917 | | { |
| 0 | 10918 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 10919 | | } |
| 5 | 10920 | | if (versionId == null) |
| | 10921 | | { |
| 0 | 10922 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 10923 | | } |
| 5 | 10924 | | if (entityRoleCreateObject == null) |
| | 10925 | | { |
| 0 | 10926 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject"); |
| | 10927 | | } |
| | 10928 | | // Tracing |
| 5 | 10929 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 5 | 10930 | | string _invocationId = null; |
| 5 | 10931 | | if (_shouldTrace) |
| | 10932 | | { |
| 0 | 10933 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 10934 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 10935 | | tracingParameters.Add("appId", appId); |
| 0 | 10936 | | tracingParameters.Add("versionId", versionId); |
| 0 | 10937 | | tracingParameters.Add("entityId", entityId); |
| 0 | 10938 | | tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject); |
| 0 | 10939 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 10940 | | ServiceClientTracing.Enter(_invocationId, this, "CreatePrebuiltEntityRole", tracingParameters); |
| | 10941 | | } |
| | 10942 | | // Construct URL |
| 5 | 10943 | | var _baseUrl = Client.BaseUri; |
| 5 | 10944 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts/{en |
| 5 | 10945 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 5 | 10946 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 5 | 10947 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 5 | 10948 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 10949 | | // Create HTTP transport objects |
| 5 | 10950 | | var _httpRequest = new HttpRequestMessage(); |
| 5 | 10951 | | HttpResponseMessage _httpResponse = null; |
| 5 | 10952 | | _httpRequest.Method = new HttpMethod("POST"); |
| 5 | 10953 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 10954 | | // Set Headers |
| | 10955 | |
|
| | 10956 | |
|
| 5 | 10957 | | if (customHeaders != null) |
| | 10958 | | { |
| 0 | 10959 | | foreach(var _header in customHeaders) |
| | 10960 | | { |
| 0 | 10961 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 10962 | | { |
| 0 | 10963 | | _httpRequest.Headers.Remove(_header.Key); |
| | 10964 | | } |
| 0 | 10965 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 10966 | | } |
| | 10967 | | } |
| | 10968 | |
|
| | 10969 | | // Serialize Request |
| 5 | 10970 | | string _requestContent = null; |
| 5 | 10971 | | if(entityRoleCreateObject != null) |
| | 10972 | | { |
| 5 | 10973 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri |
| 5 | 10974 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 5 | 10975 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 10976 | | } |
| | 10977 | | // Set Credentials |
| 5 | 10978 | | if (Client.Credentials != null) |
| | 10979 | | { |
| 5 | 10980 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 10981 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 10982 | | } |
| | 10983 | | // Send Request |
| 5 | 10984 | | if (_shouldTrace) |
| | 10985 | | { |
| 0 | 10986 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 10987 | | } |
| 5 | 10988 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 10989 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 5 | 10990 | | if (_shouldTrace) |
| | 10991 | | { |
| 0 | 10992 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 10993 | | } |
| 5 | 10994 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 5 | 10995 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 10996 | | string _responseContent = null; |
| 5 | 10997 | | if ((int)_statusCode != 201) |
| | 10998 | | { |
| 0 | 10999 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 11000 | | try |
| | 11001 | | { |
| 0 | 11002 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 11003 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 11004 | | if (_errorBody != null) |
| | 11005 | | { |
| 0 | 11006 | | ex.Body = _errorBody; |
| | 11007 | | } |
| 0 | 11008 | | } |
| 0 | 11009 | | catch (JsonException) |
| | 11010 | | { |
| | 11011 | | // Ignore the exception |
| 0 | 11012 | | } |
| 0 | 11013 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 11014 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 11015 | | if (_shouldTrace) |
| | 11016 | | { |
| 0 | 11017 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 11018 | | } |
| 0 | 11019 | | _httpRequest.Dispose(); |
| 0 | 11020 | | if (_httpResponse != null) |
| | 11021 | | { |
| 0 | 11022 | | _httpResponse.Dispose(); |
| | 11023 | | } |
| 0 | 11024 | | throw ex; |
| | 11025 | | } |
| | 11026 | | // Create Result |
| 5 | 11027 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 5 | 11028 | | _result.Request = _httpRequest; |
| 5 | 11029 | | _result.Response = _httpResponse; |
| | 11030 | | // Deserialize Response |
| 5 | 11031 | | if ((int)_statusCode == 201) |
| | 11032 | | { |
| 5 | 11033 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 11034 | | try |
| | 11035 | | { |
| 5 | 11036 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 5 | 11037 | | } |
| 0 | 11038 | | catch (JsonException ex) |
| | 11039 | | { |
| 0 | 11040 | | _httpRequest.Dispose(); |
| 0 | 11041 | | if (_httpResponse != null) |
| | 11042 | | { |
| 0 | 11043 | | _httpResponse.Dispose(); |
| | 11044 | | } |
| 0 | 11045 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 11046 | | } |
| | 11047 | | } |
| 5 | 11048 | | if (_shouldTrace) |
| | 11049 | | { |
| 0 | 11050 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 11051 | | } |
| 5 | 11052 | | return _result; |
| 5 | 11053 | | } |
| | 11054 | |
|
| | 11055 | | /// <summary> |
| | 11056 | | /// Get all roles for a list entity in a version of the application. |
| | 11057 | | /// </summary> |
| | 11058 | | /// <param name='appId'> |
| | 11059 | | /// The application ID. |
| | 11060 | | /// </param> |
| | 11061 | | /// <param name='versionId'> |
| | 11062 | | /// The version ID. |
| | 11063 | | /// </param> |
| | 11064 | | /// <param name='entityId'> |
| | 11065 | | /// entity Id |
| | 11066 | | /// </param> |
| | 11067 | | /// <param name='customHeaders'> |
| | 11068 | | /// Headers that will be added to request. |
| | 11069 | | /// </param> |
| | 11070 | | /// <param name='cancellationToken'> |
| | 11071 | | /// The cancellation token. |
| | 11072 | | /// </param> |
| | 11073 | | /// <exception cref="ErrorResponseException"> |
| | 11074 | | /// Thrown when the operation returned an invalid status code |
| | 11075 | | /// </exception> |
| | 11076 | | /// <exception cref="SerializationException"> |
| | 11077 | | /// Thrown when unable to deserialize the response |
| | 11078 | | /// </exception> |
| | 11079 | | /// <exception cref="ValidationException"> |
| | 11080 | | /// Thrown when a required parameter is null |
| | 11081 | | /// </exception> |
| | 11082 | | /// <exception cref="System.ArgumentNullException"> |
| | 11083 | | /// Thrown when a required parameter is null |
| | 11084 | | /// </exception> |
| | 11085 | | /// <return> |
| | 11086 | | /// A response object containing the response body and response headers. |
| | 11087 | | /// </return> |
| | 11088 | | public async Task<HttpOperationResponse<IList<EntityRole>>> ListClosedListEntityRolesWithHttpMessagesAsync(Syste |
| | 11089 | | { |
| 3 | 11090 | | if (Client.Endpoint == null) |
| | 11091 | | { |
| 0 | 11092 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 11093 | | } |
| 3 | 11094 | | if (versionId == null) |
| | 11095 | | { |
| 0 | 11096 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 11097 | | } |
| | 11098 | | // Tracing |
| 3 | 11099 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 3 | 11100 | | string _invocationId = null; |
| 3 | 11101 | | if (_shouldTrace) |
| | 11102 | | { |
| 0 | 11103 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 11104 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 11105 | | tracingParameters.Add("appId", appId); |
| 0 | 11106 | | tracingParameters.Add("versionId", versionId); |
| 0 | 11107 | | tracingParameters.Add("entityId", entityId); |
| 0 | 11108 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 11109 | | ServiceClientTracing.Enter(_invocationId, this, "ListClosedListEntityRoles", tracingParameters); |
| | 11110 | | } |
| | 11111 | | // Construct URL |
| 3 | 11112 | | var _baseUrl = Client.BaseUri; |
| 3 | 11113 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{ |
| 3 | 11114 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 3 | 11115 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 3 | 11116 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 3 | 11117 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 11118 | | // Create HTTP transport objects |
| 3 | 11119 | | var _httpRequest = new HttpRequestMessage(); |
| 3 | 11120 | | HttpResponseMessage _httpResponse = null; |
| 3 | 11121 | | _httpRequest.Method = new HttpMethod("GET"); |
| 3 | 11122 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 11123 | | // Set Headers |
| | 11124 | |
|
| | 11125 | |
|
| 3 | 11126 | | if (customHeaders != null) |
| | 11127 | | { |
| 0 | 11128 | | foreach(var _header in customHeaders) |
| | 11129 | | { |
| 0 | 11130 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 11131 | | { |
| 0 | 11132 | | _httpRequest.Headers.Remove(_header.Key); |
| | 11133 | | } |
| 0 | 11134 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 11135 | | } |
| | 11136 | | } |
| | 11137 | |
|
| | 11138 | | // Serialize Request |
| 3 | 11139 | | string _requestContent = null; |
| | 11140 | | // Set Credentials |
| 3 | 11141 | | if (Client.Credentials != null) |
| | 11142 | | { |
| 3 | 11143 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 11144 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 11145 | | } |
| | 11146 | | // Send Request |
| 3 | 11147 | | if (_shouldTrace) |
| | 11148 | | { |
| 0 | 11149 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 11150 | | } |
| 3 | 11151 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 11152 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 3 | 11153 | | if (_shouldTrace) |
| | 11154 | | { |
| 0 | 11155 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 11156 | | } |
| 3 | 11157 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 3 | 11158 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 11159 | | string _responseContent = null; |
| 3 | 11160 | | if ((int)_statusCode != 200) |
| | 11161 | | { |
| 0 | 11162 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 11163 | | try |
| | 11164 | | { |
| 0 | 11165 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 11166 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 11167 | | if (_errorBody != null) |
| | 11168 | | { |
| 0 | 11169 | | ex.Body = _errorBody; |
| | 11170 | | } |
| 0 | 11171 | | } |
| 0 | 11172 | | catch (JsonException) |
| | 11173 | | { |
| | 11174 | | // Ignore the exception |
| 0 | 11175 | | } |
| 0 | 11176 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 11177 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 11178 | | if (_shouldTrace) |
| | 11179 | | { |
| 0 | 11180 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 11181 | | } |
| 0 | 11182 | | _httpRequest.Dispose(); |
| 0 | 11183 | | if (_httpResponse != null) |
| | 11184 | | { |
| 0 | 11185 | | _httpResponse.Dispose(); |
| | 11186 | | } |
| 0 | 11187 | | throw ex; |
| | 11188 | | } |
| | 11189 | | // Create Result |
| 3 | 11190 | | var _result = new HttpOperationResponse<IList<EntityRole>>(); |
| 3 | 11191 | | _result.Request = _httpRequest; |
| 3 | 11192 | | _result.Response = _httpResponse; |
| | 11193 | | // Deserialize Response |
| 3 | 11194 | | if ((int)_statusCode == 200) |
| | 11195 | | { |
| 3 | 11196 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 11197 | | try |
| | 11198 | | { |
| 3 | 11199 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont |
| 3 | 11200 | | } |
| 0 | 11201 | | catch (JsonException ex) |
| | 11202 | | { |
| 0 | 11203 | | _httpRequest.Dispose(); |
| 0 | 11204 | | if (_httpResponse != null) |
| | 11205 | | { |
| 0 | 11206 | | _httpResponse.Dispose(); |
| | 11207 | | } |
| 0 | 11208 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 11209 | | } |
| | 11210 | | } |
| 3 | 11211 | | if (_shouldTrace) |
| | 11212 | | { |
| 0 | 11213 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 11214 | | } |
| 3 | 11215 | | return _result; |
| 3 | 11216 | | } |
| | 11217 | |
|
| | 11218 | | /// <summary> |
| | 11219 | | /// Create a role for a list entity in a version of the application. |
| | 11220 | | /// </summary> |
| | 11221 | | /// <param name='appId'> |
| | 11222 | | /// The application ID. |
| | 11223 | | /// </param> |
| | 11224 | | /// <param name='versionId'> |
| | 11225 | | /// The version ID. |
| | 11226 | | /// </param> |
| | 11227 | | /// <param name='entityId'> |
| | 11228 | | /// The entity model ID. |
| | 11229 | | /// </param> |
| | 11230 | | /// <param name='entityRoleCreateObject'> |
| | 11231 | | /// An entity role object containing the name of role. |
| | 11232 | | /// </param> |
| | 11233 | | /// <param name='customHeaders'> |
| | 11234 | | /// Headers that will be added to request. |
| | 11235 | | /// </param> |
| | 11236 | | /// <param name='cancellationToken'> |
| | 11237 | | /// The cancellation token. |
| | 11238 | | /// </param> |
| | 11239 | | /// <exception cref="ErrorResponseException"> |
| | 11240 | | /// Thrown when the operation returned an invalid status code |
| | 11241 | | /// </exception> |
| | 11242 | | /// <exception cref="SerializationException"> |
| | 11243 | | /// Thrown when unable to deserialize the response |
| | 11244 | | /// </exception> |
| | 11245 | | /// <exception cref="ValidationException"> |
| | 11246 | | /// Thrown when a required parameter is null |
| | 11247 | | /// </exception> |
| | 11248 | | /// <exception cref="System.ArgumentNullException"> |
| | 11249 | | /// Thrown when a required parameter is null |
| | 11250 | | /// </exception> |
| | 11251 | | /// <return> |
| | 11252 | | /// A response object containing the response body and response headers. |
| | 11253 | | /// </return> |
| | 11254 | | public async Task<HttpOperationResponse<System.Guid>> CreateClosedListEntityRoleWithHttpMessagesAsync(System.Gui |
| | 11255 | | { |
| 5 | 11256 | | if (Client.Endpoint == null) |
| | 11257 | | { |
| 0 | 11258 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 11259 | | } |
| 5 | 11260 | | if (versionId == null) |
| | 11261 | | { |
| 0 | 11262 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 11263 | | } |
| 5 | 11264 | | if (entityRoleCreateObject == null) |
| | 11265 | | { |
| 0 | 11266 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject"); |
| | 11267 | | } |
| | 11268 | | // Tracing |
| 5 | 11269 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 5 | 11270 | | string _invocationId = null; |
| 5 | 11271 | | if (_shouldTrace) |
| | 11272 | | { |
| 0 | 11273 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 11274 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 11275 | | tracingParameters.Add("appId", appId); |
| 0 | 11276 | | tracingParameters.Add("versionId", versionId); |
| 0 | 11277 | | tracingParameters.Add("entityId", entityId); |
| 0 | 11278 | | tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject); |
| 0 | 11279 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 11280 | | ServiceClientTracing.Enter(_invocationId, this, "CreateClosedListEntityRole", tracingParameters); |
| | 11281 | | } |
| | 11282 | | // Construct URL |
| 5 | 11283 | | var _baseUrl = Client.BaseUri; |
| 5 | 11284 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{ |
| 5 | 11285 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 5 | 11286 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 5 | 11287 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 5 | 11288 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 11289 | | // Create HTTP transport objects |
| 5 | 11290 | | var _httpRequest = new HttpRequestMessage(); |
| 5 | 11291 | | HttpResponseMessage _httpResponse = null; |
| 5 | 11292 | | _httpRequest.Method = new HttpMethod("POST"); |
| 5 | 11293 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 11294 | | // Set Headers |
| | 11295 | |
|
| | 11296 | |
|
| 5 | 11297 | | if (customHeaders != null) |
| | 11298 | | { |
| 0 | 11299 | | foreach(var _header in customHeaders) |
| | 11300 | | { |
| 0 | 11301 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 11302 | | { |
| 0 | 11303 | | _httpRequest.Headers.Remove(_header.Key); |
| | 11304 | | } |
| 0 | 11305 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 11306 | | } |
| | 11307 | | } |
| | 11308 | |
|
| | 11309 | | // Serialize Request |
| 5 | 11310 | | string _requestContent = null; |
| 5 | 11311 | | if(entityRoleCreateObject != null) |
| | 11312 | | { |
| 5 | 11313 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri |
| 5 | 11314 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 5 | 11315 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 11316 | | } |
| | 11317 | | // Set Credentials |
| 5 | 11318 | | if (Client.Credentials != null) |
| | 11319 | | { |
| 5 | 11320 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 11321 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 11322 | | } |
| | 11323 | | // Send Request |
| 5 | 11324 | | if (_shouldTrace) |
| | 11325 | | { |
| 0 | 11326 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 11327 | | } |
| 5 | 11328 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 11329 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 5 | 11330 | | if (_shouldTrace) |
| | 11331 | | { |
| 0 | 11332 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 11333 | | } |
| 5 | 11334 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 5 | 11335 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 11336 | | string _responseContent = null; |
| 5 | 11337 | | if ((int)_statusCode != 201) |
| | 11338 | | { |
| 0 | 11339 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 11340 | | try |
| | 11341 | | { |
| 0 | 11342 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 11343 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 11344 | | if (_errorBody != null) |
| | 11345 | | { |
| 0 | 11346 | | ex.Body = _errorBody; |
| | 11347 | | } |
| 0 | 11348 | | } |
| 0 | 11349 | | catch (JsonException) |
| | 11350 | | { |
| | 11351 | | // Ignore the exception |
| 0 | 11352 | | } |
| 0 | 11353 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 11354 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 11355 | | if (_shouldTrace) |
| | 11356 | | { |
| 0 | 11357 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 11358 | | } |
| 0 | 11359 | | _httpRequest.Dispose(); |
| 0 | 11360 | | if (_httpResponse != null) |
| | 11361 | | { |
| 0 | 11362 | | _httpResponse.Dispose(); |
| | 11363 | | } |
| 0 | 11364 | | throw ex; |
| | 11365 | | } |
| | 11366 | | // Create Result |
| 5 | 11367 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 5 | 11368 | | _result.Request = _httpRequest; |
| 5 | 11369 | | _result.Response = _httpResponse; |
| | 11370 | | // Deserialize Response |
| 5 | 11371 | | if ((int)_statusCode == 201) |
| | 11372 | | { |
| 5 | 11373 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 11374 | | try |
| | 11375 | | { |
| 5 | 11376 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 5 | 11377 | | } |
| 0 | 11378 | | catch (JsonException ex) |
| | 11379 | | { |
| 0 | 11380 | | _httpRequest.Dispose(); |
| 0 | 11381 | | if (_httpResponse != null) |
| | 11382 | | { |
| 0 | 11383 | | _httpResponse.Dispose(); |
| | 11384 | | } |
| 0 | 11385 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 11386 | | } |
| | 11387 | | } |
| 5 | 11388 | | if (_shouldTrace) |
| | 11389 | | { |
| 0 | 11390 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 11391 | | } |
| 5 | 11392 | | return _result; |
| 5 | 11393 | | } |
| | 11394 | |
|
| | 11395 | | /// <summary> |
| | 11396 | | /// Get all roles for a regular expression entity in a version of the |
| | 11397 | | /// application. |
| | 11398 | | /// </summary> |
| | 11399 | | /// <param name='appId'> |
| | 11400 | | /// The application ID. |
| | 11401 | | /// </param> |
| | 11402 | | /// <param name='versionId'> |
| | 11403 | | /// The version ID. |
| | 11404 | | /// </param> |
| | 11405 | | /// <param name='entityId'> |
| | 11406 | | /// entity Id |
| | 11407 | | /// </param> |
| | 11408 | | /// <param name='customHeaders'> |
| | 11409 | | /// Headers that will be added to request. |
| | 11410 | | /// </param> |
| | 11411 | | /// <param name='cancellationToken'> |
| | 11412 | | /// The cancellation token. |
| | 11413 | | /// </param> |
| | 11414 | | /// <exception cref="ErrorResponseException"> |
| | 11415 | | /// Thrown when the operation returned an invalid status code |
| | 11416 | | /// </exception> |
| | 11417 | | /// <exception cref="SerializationException"> |
| | 11418 | | /// Thrown when unable to deserialize the response |
| | 11419 | | /// </exception> |
| | 11420 | | /// <exception cref="ValidationException"> |
| | 11421 | | /// Thrown when a required parameter is null |
| | 11422 | | /// </exception> |
| | 11423 | | /// <exception cref="System.ArgumentNullException"> |
| | 11424 | | /// Thrown when a required parameter is null |
| | 11425 | | /// </exception> |
| | 11426 | | /// <return> |
| | 11427 | | /// A response object containing the response body and response headers. |
| | 11428 | | /// </return> |
| | 11429 | | public async Task<HttpOperationResponse<IList<EntityRole>>> ListRegexEntityRolesWithHttpMessagesAsync(System.Gui |
| | 11430 | | { |
| 3 | 11431 | | if (Client.Endpoint == null) |
| | 11432 | | { |
| 0 | 11433 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 11434 | | } |
| 3 | 11435 | | if (versionId == null) |
| | 11436 | | { |
| 0 | 11437 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 11438 | | } |
| | 11439 | | // Tracing |
| 3 | 11440 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 3 | 11441 | | string _invocationId = null; |
| 3 | 11442 | | if (_shouldTrace) |
| | 11443 | | { |
| 0 | 11444 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 11445 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 11446 | | tracingParameters.Add("appId", appId); |
| 0 | 11447 | | tracingParameters.Add("versionId", versionId); |
| 0 | 11448 | | tracingParameters.Add("entityId", entityId); |
| 0 | 11449 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 11450 | | ServiceClientTracing.Enter(_invocationId, this, "ListRegexEntityRoles", tracingParameters); |
| | 11451 | | } |
| | 11452 | | // Construct URL |
| 3 | 11453 | | var _baseUrl = Client.BaseUri; |
| 3 | 11454 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities |
| 3 | 11455 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 3 | 11456 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 3 | 11457 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 3 | 11458 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 11459 | | // Create HTTP transport objects |
| 3 | 11460 | | var _httpRequest = new HttpRequestMessage(); |
| 3 | 11461 | | HttpResponseMessage _httpResponse = null; |
| 3 | 11462 | | _httpRequest.Method = new HttpMethod("GET"); |
| 3 | 11463 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 11464 | | // Set Headers |
| | 11465 | |
|
| | 11466 | |
|
| 3 | 11467 | | if (customHeaders != null) |
| | 11468 | | { |
| 0 | 11469 | | foreach(var _header in customHeaders) |
| | 11470 | | { |
| 0 | 11471 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 11472 | | { |
| 0 | 11473 | | _httpRequest.Headers.Remove(_header.Key); |
| | 11474 | | } |
| 0 | 11475 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 11476 | | } |
| | 11477 | | } |
| | 11478 | |
|
| | 11479 | | // Serialize Request |
| 3 | 11480 | | string _requestContent = null; |
| | 11481 | | // Set Credentials |
| 3 | 11482 | | if (Client.Credentials != null) |
| | 11483 | | { |
| 3 | 11484 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 11485 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 11486 | | } |
| | 11487 | | // Send Request |
| 3 | 11488 | | if (_shouldTrace) |
| | 11489 | | { |
| 0 | 11490 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 11491 | | } |
| 3 | 11492 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 11493 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 3 | 11494 | | if (_shouldTrace) |
| | 11495 | | { |
| 0 | 11496 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 11497 | | } |
| 3 | 11498 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 3 | 11499 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 11500 | | string _responseContent = null; |
| 3 | 11501 | | if ((int)_statusCode != 200) |
| | 11502 | | { |
| 0 | 11503 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 11504 | | try |
| | 11505 | | { |
| 0 | 11506 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 11507 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 11508 | | if (_errorBody != null) |
| | 11509 | | { |
| 0 | 11510 | | ex.Body = _errorBody; |
| | 11511 | | } |
| 0 | 11512 | | } |
| 0 | 11513 | | catch (JsonException) |
| | 11514 | | { |
| | 11515 | | // Ignore the exception |
| 0 | 11516 | | } |
| 0 | 11517 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 11518 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 11519 | | if (_shouldTrace) |
| | 11520 | | { |
| 0 | 11521 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 11522 | | } |
| 0 | 11523 | | _httpRequest.Dispose(); |
| 0 | 11524 | | if (_httpResponse != null) |
| | 11525 | | { |
| 0 | 11526 | | _httpResponse.Dispose(); |
| | 11527 | | } |
| 0 | 11528 | | throw ex; |
| | 11529 | | } |
| | 11530 | | // Create Result |
| 3 | 11531 | | var _result = new HttpOperationResponse<IList<EntityRole>>(); |
| 3 | 11532 | | _result.Request = _httpRequest; |
| 3 | 11533 | | _result.Response = _httpResponse; |
| | 11534 | | // Deserialize Response |
| 3 | 11535 | | if ((int)_statusCode == 200) |
| | 11536 | | { |
| 3 | 11537 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 11538 | | try |
| | 11539 | | { |
| 3 | 11540 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont |
| 3 | 11541 | | } |
| 0 | 11542 | | catch (JsonException ex) |
| | 11543 | | { |
| 0 | 11544 | | _httpRequest.Dispose(); |
| 0 | 11545 | | if (_httpResponse != null) |
| | 11546 | | { |
| 0 | 11547 | | _httpResponse.Dispose(); |
| | 11548 | | } |
| 0 | 11549 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 11550 | | } |
| | 11551 | | } |
| 3 | 11552 | | if (_shouldTrace) |
| | 11553 | | { |
| 0 | 11554 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 11555 | | } |
| 3 | 11556 | | return _result; |
| 3 | 11557 | | } |
| | 11558 | |
|
| | 11559 | | /// <summary> |
| | 11560 | | /// Create a role for an regular expression entity in a version of the |
| | 11561 | | /// application. |
| | 11562 | | /// </summary> |
| | 11563 | | /// <param name='appId'> |
| | 11564 | | /// The application ID. |
| | 11565 | | /// </param> |
| | 11566 | | /// <param name='versionId'> |
| | 11567 | | /// The version ID. |
| | 11568 | | /// </param> |
| | 11569 | | /// <param name='entityId'> |
| | 11570 | | /// The entity model ID. |
| | 11571 | | /// </param> |
| | 11572 | | /// <param name='entityRoleCreateObject'> |
| | 11573 | | /// An entity role object containing the name of role. |
| | 11574 | | /// </param> |
| | 11575 | | /// <param name='customHeaders'> |
| | 11576 | | /// Headers that will be added to request. |
| | 11577 | | /// </param> |
| | 11578 | | /// <param name='cancellationToken'> |
| | 11579 | | /// The cancellation token. |
| | 11580 | | /// </param> |
| | 11581 | | /// <exception cref="ErrorResponseException"> |
| | 11582 | | /// Thrown when the operation returned an invalid status code |
| | 11583 | | /// </exception> |
| | 11584 | | /// <exception cref="SerializationException"> |
| | 11585 | | /// Thrown when unable to deserialize the response |
| | 11586 | | /// </exception> |
| | 11587 | | /// <exception cref="ValidationException"> |
| | 11588 | | /// Thrown when a required parameter is null |
| | 11589 | | /// </exception> |
| | 11590 | | /// <exception cref="System.ArgumentNullException"> |
| | 11591 | | /// Thrown when a required parameter is null |
| | 11592 | | /// </exception> |
| | 11593 | | /// <return> |
| | 11594 | | /// A response object containing the response body and response headers. |
| | 11595 | | /// </return> |
| | 11596 | | public async Task<HttpOperationResponse<System.Guid>> CreateRegexEntityRoleWithHttpMessagesAsync(System.Guid app |
| | 11597 | | { |
| 5 | 11598 | | if (Client.Endpoint == null) |
| | 11599 | | { |
| 0 | 11600 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 11601 | | } |
| 5 | 11602 | | if (versionId == null) |
| | 11603 | | { |
| 0 | 11604 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 11605 | | } |
| 5 | 11606 | | if (entityRoleCreateObject == null) |
| | 11607 | | { |
| 0 | 11608 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject"); |
| | 11609 | | } |
| | 11610 | | // Tracing |
| 5 | 11611 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 5 | 11612 | | string _invocationId = null; |
| 5 | 11613 | | if (_shouldTrace) |
| | 11614 | | { |
| 0 | 11615 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 11616 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 11617 | | tracingParameters.Add("appId", appId); |
| 0 | 11618 | | tracingParameters.Add("versionId", versionId); |
| 0 | 11619 | | tracingParameters.Add("entityId", entityId); |
| 0 | 11620 | | tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject); |
| 0 | 11621 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 11622 | | ServiceClientTracing.Enter(_invocationId, this, "CreateRegexEntityRole", tracingParameters); |
| | 11623 | | } |
| | 11624 | | // Construct URL |
| 5 | 11625 | | var _baseUrl = Client.BaseUri; |
| 5 | 11626 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities |
| 5 | 11627 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 5 | 11628 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 5 | 11629 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 5 | 11630 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 11631 | | // Create HTTP transport objects |
| 5 | 11632 | | var _httpRequest = new HttpRequestMessage(); |
| 5 | 11633 | | HttpResponseMessage _httpResponse = null; |
| 5 | 11634 | | _httpRequest.Method = new HttpMethod("POST"); |
| 5 | 11635 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 11636 | | // Set Headers |
| | 11637 | |
|
| | 11638 | |
|
| 5 | 11639 | | if (customHeaders != null) |
| | 11640 | | { |
| 0 | 11641 | | foreach(var _header in customHeaders) |
| | 11642 | | { |
| 0 | 11643 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 11644 | | { |
| 0 | 11645 | | _httpRequest.Headers.Remove(_header.Key); |
| | 11646 | | } |
| 0 | 11647 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 11648 | | } |
| | 11649 | | } |
| | 11650 | |
|
| | 11651 | | // Serialize Request |
| 5 | 11652 | | string _requestContent = null; |
| 5 | 11653 | | if(entityRoleCreateObject != null) |
| | 11654 | | { |
| 5 | 11655 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri |
| 5 | 11656 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 5 | 11657 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 11658 | | } |
| | 11659 | | // Set Credentials |
| 5 | 11660 | | if (Client.Credentials != null) |
| | 11661 | | { |
| 5 | 11662 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 11663 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 11664 | | } |
| | 11665 | | // Send Request |
| 5 | 11666 | | if (_shouldTrace) |
| | 11667 | | { |
| 0 | 11668 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 11669 | | } |
| 5 | 11670 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 11671 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 5 | 11672 | | if (_shouldTrace) |
| | 11673 | | { |
| 0 | 11674 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 11675 | | } |
| 5 | 11676 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 5 | 11677 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 11678 | | string _responseContent = null; |
| 5 | 11679 | | if ((int)_statusCode != 201) |
| | 11680 | | { |
| 0 | 11681 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 11682 | | try |
| | 11683 | | { |
| 0 | 11684 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 11685 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 11686 | | if (_errorBody != null) |
| | 11687 | | { |
| 0 | 11688 | | ex.Body = _errorBody; |
| | 11689 | | } |
| 0 | 11690 | | } |
| 0 | 11691 | | catch (JsonException) |
| | 11692 | | { |
| | 11693 | | // Ignore the exception |
| 0 | 11694 | | } |
| 0 | 11695 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 11696 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 11697 | | if (_shouldTrace) |
| | 11698 | | { |
| 0 | 11699 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 11700 | | } |
| 0 | 11701 | | _httpRequest.Dispose(); |
| 0 | 11702 | | if (_httpResponse != null) |
| | 11703 | | { |
| 0 | 11704 | | _httpResponse.Dispose(); |
| | 11705 | | } |
| 0 | 11706 | | throw ex; |
| | 11707 | | } |
| | 11708 | | // Create Result |
| 5 | 11709 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 5 | 11710 | | _result.Request = _httpRequest; |
| 5 | 11711 | | _result.Response = _httpResponse; |
| | 11712 | | // Deserialize Response |
| 5 | 11713 | | if ((int)_statusCode == 201) |
| | 11714 | | { |
| 5 | 11715 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 11716 | | try |
| | 11717 | | { |
| 5 | 11718 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 5 | 11719 | | } |
| 0 | 11720 | | catch (JsonException ex) |
| | 11721 | | { |
| 0 | 11722 | | _httpRequest.Dispose(); |
| 0 | 11723 | | if (_httpResponse != null) |
| | 11724 | | { |
| 0 | 11725 | | _httpResponse.Dispose(); |
| | 11726 | | } |
| 0 | 11727 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 11728 | | } |
| | 11729 | | } |
| 5 | 11730 | | if (_shouldTrace) |
| | 11731 | | { |
| 0 | 11732 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 11733 | | } |
| 5 | 11734 | | return _result; |
| 5 | 11735 | | } |
| | 11736 | |
|
| | 11737 | | /// <summary> |
| | 11738 | | /// Get all roles for a composite entity in a version of the application |
| | 11739 | | /// </summary> |
| | 11740 | | /// <param name='appId'> |
| | 11741 | | /// The application ID. |
| | 11742 | | /// </param> |
| | 11743 | | /// <param name='versionId'> |
| | 11744 | | /// The version ID. |
| | 11745 | | /// </param> |
| | 11746 | | /// <param name='cEntityId'> |
| | 11747 | | /// The composite entity extractor ID. |
| | 11748 | | /// </param> |
| | 11749 | | /// <param name='customHeaders'> |
| | 11750 | | /// Headers that will be added to request. |
| | 11751 | | /// </param> |
| | 11752 | | /// <param name='cancellationToken'> |
| | 11753 | | /// The cancellation token. |
| | 11754 | | /// </param> |
| | 11755 | | /// <exception cref="ErrorResponseException"> |
| | 11756 | | /// Thrown when the operation returned an invalid status code |
| | 11757 | | /// </exception> |
| | 11758 | | /// <exception cref="SerializationException"> |
| | 11759 | | /// Thrown when unable to deserialize the response |
| | 11760 | | /// </exception> |
| | 11761 | | /// <exception cref="ValidationException"> |
| | 11762 | | /// Thrown when a required parameter is null |
| | 11763 | | /// </exception> |
| | 11764 | | /// <exception cref="System.ArgumentNullException"> |
| | 11765 | | /// Thrown when a required parameter is null |
| | 11766 | | /// </exception> |
| | 11767 | | /// <return> |
| | 11768 | | /// A response object containing the response body and response headers. |
| | 11769 | | /// </return> |
| | 11770 | | public async Task<HttpOperationResponse<IList<EntityRole>>> ListCompositeEntityRolesWithHttpMessagesAsync(System |
| | 11771 | | { |
| 0 | 11772 | | if (Client.Endpoint == null) |
| | 11773 | | { |
| 0 | 11774 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 11775 | | } |
| 0 | 11776 | | if (versionId == null) |
| | 11777 | | { |
| 0 | 11778 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 11779 | | } |
| | 11780 | | // Tracing |
| 0 | 11781 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 11782 | | string _invocationId = null; |
| 0 | 11783 | | if (_shouldTrace) |
| | 11784 | | { |
| 0 | 11785 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 11786 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 11787 | | tracingParameters.Add("appId", appId); |
| 0 | 11788 | | tracingParameters.Add("versionId", versionId); |
| 0 | 11789 | | tracingParameters.Add("cEntityId", cEntityId); |
| 0 | 11790 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 11791 | | ServiceClientTracing.Enter(_invocationId, this, "ListCompositeEntityRoles", tracingParameters); |
| | 11792 | | } |
| | 11793 | | // Construct URL |
| 0 | 11794 | | var _baseUrl = Client.BaseUri; |
| 0 | 11795 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti |
| 0 | 11796 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 11797 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 11798 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 11799 | | _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| | 11800 | | // Create HTTP transport objects |
| 0 | 11801 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 11802 | | HttpResponseMessage _httpResponse = null; |
| 0 | 11803 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 11804 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 11805 | | // Set Headers |
| | 11806 | |
|
| | 11807 | |
|
| 0 | 11808 | | if (customHeaders != null) |
| | 11809 | | { |
| 0 | 11810 | | foreach(var _header in customHeaders) |
| | 11811 | | { |
| 0 | 11812 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 11813 | | { |
| 0 | 11814 | | _httpRequest.Headers.Remove(_header.Key); |
| | 11815 | | } |
| 0 | 11816 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 11817 | | } |
| | 11818 | | } |
| | 11819 | |
|
| | 11820 | | // Serialize Request |
| 0 | 11821 | | string _requestContent = null; |
| | 11822 | | // Set Credentials |
| 0 | 11823 | | if (Client.Credentials != null) |
| | 11824 | | { |
| 0 | 11825 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 11826 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 11827 | | } |
| | 11828 | | // Send Request |
| 0 | 11829 | | if (_shouldTrace) |
| | 11830 | | { |
| 0 | 11831 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 11832 | | } |
| 0 | 11833 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 11834 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 11835 | | if (_shouldTrace) |
| | 11836 | | { |
| 0 | 11837 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 11838 | | } |
| 0 | 11839 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 11840 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 11841 | | string _responseContent = null; |
| 0 | 11842 | | if ((int)_statusCode != 200) |
| | 11843 | | { |
| 0 | 11844 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 11845 | | try |
| | 11846 | | { |
| 0 | 11847 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 11848 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 11849 | | if (_errorBody != null) |
| | 11850 | | { |
| 0 | 11851 | | ex.Body = _errorBody; |
| | 11852 | | } |
| 0 | 11853 | | } |
| 0 | 11854 | | catch (JsonException) |
| | 11855 | | { |
| | 11856 | | // Ignore the exception |
| 0 | 11857 | | } |
| 0 | 11858 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 11859 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 11860 | | if (_shouldTrace) |
| | 11861 | | { |
| 0 | 11862 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 11863 | | } |
| 0 | 11864 | | _httpRequest.Dispose(); |
| 0 | 11865 | | if (_httpResponse != null) |
| | 11866 | | { |
| 0 | 11867 | | _httpResponse.Dispose(); |
| | 11868 | | } |
| 0 | 11869 | | throw ex; |
| | 11870 | | } |
| | 11871 | | // Create Result |
| 0 | 11872 | | var _result = new HttpOperationResponse<IList<EntityRole>>(); |
| 0 | 11873 | | _result.Request = _httpRequest; |
| 0 | 11874 | | _result.Response = _httpResponse; |
| | 11875 | | // Deserialize Response |
| 0 | 11876 | | if ((int)_statusCode == 200) |
| | 11877 | | { |
| 0 | 11878 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 11879 | | try |
| | 11880 | | { |
| 0 | 11881 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont |
| 0 | 11882 | | } |
| 0 | 11883 | | catch (JsonException ex) |
| | 11884 | | { |
| 0 | 11885 | | _httpRequest.Dispose(); |
| 0 | 11886 | | if (_httpResponse != null) |
| | 11887 | | { |
| 0 | 11888 | | _httpResponse.Dispose(); |
| | 11889 | | } |
| 0 | 11890 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 11891 | | } |
| | 11892 | | } |
| 0 | 11893 | | if (_shouldTrace) |
| | 11894 | | { |
| 0 | 11895 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 11896 | | } |
| 0 | 11897 | | return _result; |
| 0 | 11898 | | } |
| | 11899 | |
|
| | 11900 | | /// <summary> |
| | 11901 | | /// Create a role for a composite entity in a version of the application. |
| | 11902 | | /// </summary> |
| | 11903 | | /// <param name='appId'> |
| | 11904 | | /// The application ID. |
| | 11905 | | /// </param> |
| | 11906 | | /// <param name='versionId'> |
| | 11907 | | /// The version ID. |
| | 11908 | | /// </param> |
| | 11909 | | /// <param name='cEntityId'> |
| | 11910 | | /// The composite entity extractor ID. |
| | 11911 | | /// </param> |
| | 11912 | | /// <param name='entityRoleCreateObject'> |
| | 11913 | | /// An entity role object containing the name of role. |
| | 11914 | | /// </param> |
| | 11915 | | /// <param name='customHeaders'> |
| | 11916 | | /// Headers that will be added to request. |
| | 11917 | | /// </param> |
| | 11918 | | /// <param name='cancellationToken'> |
| | 11919 | | /// The cancellation token. |
| | 11920 | | /// </param> |
| | 11921 | | /// <exception cref="ErrorResponseException"> |
| | 11922 | | /// Thrown when the operation returned an invalid status code |
| | 11923 | | /// </exception> |
| | 11924 | | /// <exception cref="SerializationException"> |
| | 11925 | | /// Thrown when unable to deserialize the response |
| | 11926 | | /// </exception> |
| | 11927 | | /// <exception cref="ValidationException"> |
| | 11928 | | /// Thrown when a required parameter is null |
| | 11929 | | /// </exception> |
| | 11930 | | /// <exception cref="System.ArgumentNullException"> |
| | 11931 | | /// Thrown when a required parameter is null |
| | 11932 | | /// </exception> |
| | 11933 | | /// <return> |
| | 11934 | | /// A response object containing the response body and response headers. |
| | 11935 | | /// </return> |
| | 11936 | | public async Task<HttpOperationResponse<System.Guid>> CreateCompositeEntityRoleWithHttpMessagesAsync(System.Guid |
| | 11937 | | { |
| 0 | 11938 | | if (Client.Endpoint == null) |
| | 11939 | | { |
| 0 | 11940 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 11941 | | } |
| 0 | 11942 | | if (versionId == null) |
| | 11943 | | { |
| 0 | 11944 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 11945 | | } |
| 0 | 11946 | | if (entityRoleCreateObject == null) |
| | 11947 | | { |
| 0 | 11948 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject"); |
| | 11949 | | } |
| | 11950 | | // Tracing |
| 0 | 11951 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 11952 | | string _invocationId = null; |
| 0 | 11953 | | if (_shouldTrace) |
| | 11954 | | { |
| 0 | 11955 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 11956 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 11957 | | tracingParameters.Add("appId", appId); |
| 0 | 11958 | | tracingParameters.Add("versionId", versionId); |
| 0 | 11959 | | tracingParameters.Add("cEntityId", cEntityId); |
| 0 | 11960 | | tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject); |
| 0 | 11961 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 11962 | | ServiceClientTracing.Enter(_invocationId, this, "CreateCompositeEntityRole", tracingParameters); |
| | 11963 | | } |
| | 11964 | | // Construct URL |
| 0 | 11965 | | var _baseUrl = Client.BaseUri; |
| 0 | 11966 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti |
| 0 | 11967 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 11968 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 11969 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 11970 | | _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| | 11971 | | // Create HTTP transport objects |
| 0 | 11972 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 11973 | | HttpResponseMessage _httpResponse = null; |
| 0 | 11974 | | _httpRequest.Method = new HttpMethod("POST"); |
| 0 | 11975 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 11976 | | // Set Headers |
| | 11977 | |
|
| | 11978 | |
|
| 0 | 11979 | | if (customHeaders != null) |
| | 11980 | | { |
| 0 | 11981 | | foreach(var _header in customHeaders) |
| | 11982 | | { |
| 0 | 11983 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 11984 | | { |
| 0 | 11985 | | _httpRequest.Headers.Remove(_header.Key); |
| | 11986 | | } |
| 0 | 11987 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 11988 | | } |
| | 11989 | | } |
| | 11990 | |
|
| | 11991 | | // Serialize Request |
| 0 | 11992 | | string _requestContent = null; |
| 0 | 11993 | | if(entityRoleCreateObject != null) |
| | 11994 | | { |
| 0 | 11995 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri |
| 0 | 11996 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 11997 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 11998 | | } |
| | 11999 | | // Set Credentials |
| 0 | 12000 | | if (Client.Credentials != null) |
| | 12001 | | { |
| 0 | 12002 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 12003 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 12004 | | } |
| | 12005 | | // Send Request |
| 0 | 12006 | | if (_shouldTrace) |
| | 12007 | | { |
| 0 | 12008 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 12009 | | } |
| 0 | 12010 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 12011 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 12012 | | if (_shouldTrace) |
| | 12013 | | { |
| 0 | 12014 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 12015 | | } |
| 0 | 12016 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 12017 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 12018 | | string _responseContent = null; |
| 0 | 12019 | | if ((int)_statusCode != 201) |
| | 12020 | | { |
| 0 | 12021 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 12022 | | try |
| | 12023 | | { |
| 0 | 12024 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 12025 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 12026 | | if (_errorBody != null) |
| | 12027 | | { |
| 0 | 12028 | | ex.Body = _errorBody; |
| | 12029 | | } |
| 0 | 12030 | | } |
| 0 | 12031 | | catch (JsonException) |
| | 12032 | | { |
| | 12033 | | // Ignore the exception |
| 0 | 12034 | | } |
| 0 | 12035 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 12036 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 12037 | | if (_shouldTrace) |
| | 12038 | | { |
| 0 | 12039 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 12040 | | } |
| 0 | 12041 | | _httpRequest.Dispose(); |
| 0 | 12042 | | if (_httpResponse != null) |
| | 12043 | | { |
| 0 | 12044 | | _httpResponse.Dispose(); |
| | 12045 | | } |
| 0 | 12046 | | throw ex; |
| | 12047 | | } |
| | 12048 | | // Create Result |
| 0 | 12049 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 0 | 12050 | | _result.Request = _httpRequest; |
| 0 | 12051 | | _result.Response = _httpResponse; |
| | 12052 | | // Deserialize Response |
| 0 | 12053 | | if ((int)_statusCode == 201) |
| | 12054 | | { |
| 0 | 12055 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 12056 | | try |
| | 12057 | | { |
| 0 | 12058 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 0 | 12059 | | } |
| 0 | 12060 | | catch (JsonException ex) |
| | 12061 | | { |
| 0 | 12062 | | _httpRequest.Dispose(); |
| 0 | 12063 | | if (_httpResponse != null) |
| | 12064 | | { |
| 0 | 12065 | | _httpResponse.Dispose(); |
| | 12066 | | } |
| 0 | 12067 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 12068 | | } |
| | 12069 | | } |
| 0 | 12070 | | if (_shouldTrace) |
| | 12071 | | { |
| 0 | 12072 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 12073 | | } |
| 0 | 12074 | | return _result; |
| 0 | 12075 | | } |
| | 12076 | |
|
| | 12077 | | /// <summary> |
| | 12078 | | /// Get all roles for a Pattern.any entity in a version of the application |
| | 12079 | | /// </summary> |
| | 12080 | | /// <param name='appId'> |
| | 12081 | | /// The application ID. |
| | 12082 | | /// </param> |
| | 12083 | | /// <param name='versionId'> |
| | 12084 | | /// The version ID. |
| | 12085 | | /// </param> |
| | 12086 | | /// <param name='entityId'> |
| | 12087 | | /// entity Id |
| | 12088 | | /// </param> |
| | 12089 | | /// <param name='customHeaders'> |
| | 12090 | | /// Headers that will be added to request. |
| | 12091 | | /// </param> |
| | 12092 | | /// <param name='cancellationToken'> |
| | 12093 | | /// The cancellation token. |
| | 12094 | | /// </param> |
| | 12095 | | /// <exception cref="ErrorResponseException"> |
| | 12096 | | /// Thrown when the operation returned an invalid status code |
| | 12097 | | /// </exception> |
| | 12098 | | /// <exception cref="SerializationException"> |
| | 12099 | | /// Thrown when unable to deserialize the response |
| | 12100 | | /// </exception> |
| | 12101 | | /// <exception cref="ValidationException"> |
| | 12102 | | /// Thrown when a required parameter is null |
| | 12103 | | /// </exception> |
| | 12104 | | /// <exception cref="System.ArgumentNullException"> |
| | 12105 | | /// Thrown when a required parameter is null |
| | 12106 | | /// </exception> |
| | 12107 | | /// <return> |
| | 12108 | | /// A response object containing the response body and response headers. |
| | 12109 | | /// </return> |
| | 12110 | | public async Task<HttpOperationResponse<IList<EntityRole>>> ListPatternAnyEntityRolesWithHttpMessagesAsync(Syste |
| | 12111 | | { |
| 3 | 12112 | | if (Client.Endpoint == null) |
| | 12113 | | { |
| 0 | 12114 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 12115 | | } |
| 3 | 12116 | | if (versionId == null) |
| | 12117 | | { |
| 0 | 12118 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 12119 | | } |
| | 12120 | | // Tracing |
| 3 | 12121 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 3 | 12122 | | string _invocationId = null; |
| 3 | 12123 | | if (_shouldTrace) |
| | 12124 | | { |
| 0 | 12125 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 12126 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 12127 | | tracingParameters.Add("appId", appId); |
| 0 | 12128 | | tracingParameters.Add("versionId", versionId); |
| 0 | 12129 | | tracingParameters.Add("entityId", entityId); |
| 0 | 12130 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 12131 | | ServiceClientTracing.Enter(_invocationId, this, "ListPatternAnyEntityRoles", tracingParameters); |
| | 12132 | | } |
| | 12133 | | // Construct URL |
| 3 | 12134 | | var _baseUrl = Client.BaseUri; |
| 3 | 12135 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 3 | 12136 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 3 | 12137 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 3 | 12138 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 3 | 12139 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 12140 | | // Create HTTP transport objects |
| 3 | 12141 | | var _httpRequest = new HttpRequestMessage(); |
| 3 | 12142 | | HttpResponseMessage _httpResponse = null; |
| 3 | 12143 | | _httpRequest.Method = new HttpMethod("GET"); |
| 3 | 12144 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 12145 | | // Set Headers |
| | 12146 | |
|
| | 12147 | |
|
| 3 | 12148 | | if (customHeaders != null) |
| | 12149 | | { |
| 0 | 12150 | | foreach(var _header in customHeaders) |
| | 12151 | | { |
| 0 | 12152 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 12153 | | { |
| 0 | 12154 | | _httpRequest.Headers.Remove(_header.Key); |
| | 12155 | | } |
| 0 | 12156 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 12157 | | } |
| | 12158 | | } |
| | 12159 | |
|
| | 12160 | | // Serialize Request |
| 3 | 12161 | | string _requestContent = null; |
| | 12162 | | // Set Credentials |
| 3 | 12163 | | if (Client.Credentials != null) |
| | 12164 | | { |
| 3 | 12165 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 12166 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 12167 | | } |
| | 12168 | | // Send Request |
| 3 | 12169 | | if (_shouldTrace) |
| | 12170 | | { |
| 0 | 12171 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 12172 | | } |
| 3 | 12173 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 12174 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 3 | 12175 | | if (_shouldTrace) |
| | 12176 | | { |
| 0 | 12177 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 12178 | | } |
| 3 | 12179 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 3 | 12180 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 12181 | | string _responseContent = null; |
| 3 | 12182 | | if ((int)_statusCode != 200) |
| | 12183 | | { |
| 0 | 12184 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 12185 | | try |
| | 12186 | | { |
| 0 | 12187 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 12188 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 12189 | | if (_errorBody != null) |
| | 12190 | | { |
| 0 | 12191 | | ex.Body = _errorBody; |
| | 12192 | | } |
| 0 | 12193 | | } |
| 0 | 12194 | | catch (JsonException) |
| | 12195 | | { |
| | 12196 | | // Ignore the exception |
| 0 | 12197 | | } |
| 0 | 12198 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 12199 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 12200 | | if (_shouldTrace) |
| | 12201 | | { |
| 0 | 12202 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 12203 | | } |
| 0 | 12204 | | _httpRequest.Dispose(); |
| 0 | 12205 | | if (_httpResponse != null) |
| | 12206 | | { |
| 0 | 12207 | | _httpResponse.Dispose(); |
| | 12208 | | } |
| 0 | 12209 | | throw ex; |
| | 12210 | | } |
| | 12211 | | // Create Result |
| 3 | 12212 | | var _result = new HttpOperationResponse<IList<EntityRole>>(); |
| 3 | 12213 | | _result.Request = _httpRequest; |
| 3 | 12214 | | _result.Response = _httpResponse; |
| | 12215 | | // Deserialize Response |
| 3 | 12216 | | if ((int)_statusCode == 200) |
| | 12217 | | { |
| 3 | 12218 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 12219 | | try |
| | 12220 | | { |
| 3 | 12221 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont |
| 3 | 12222 | | } |
| 0 | 12223 | | catch (JsonException ex) |
| | 12224 | | { |
| 0 | 12225 | | _httpRequest.Dispose(); |
| 0 | 12226 | | if (_httpResponse != null) |
| | 12227 | | { |
| 0 | 12228 | | _httpResponse.Dispose(); |
| | 12229 | | } |
| 0 | 12230 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 12231 | | } |
| | 12232 | | } |
| 3 | 12233 | | if (_shouldTrace) |
| | 12234 | | { |
| 0 | 12235 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 12236 | | } |
| 3 | 12237 | | return _result; |
| 3 | 12238 | | } |
| | 12239 | |
|
| | 12240 | | /// <summary> |
| | 12241 | | /// Create a role for an Pattern.any entity in a version of the application. |
| | 12242 | | /// </summary> |
| | 12243 | | /// <param name='appId'> |
| | 12244 | | /// The application ID. |
| | 12245 | | /// </param> |
| | 12246 | | /// <param name='versionId'> |
| | 12247 | | /// The version ID. |
| | 12248 | | /// </param> |
| | 12249 | | /// <param name='entityId'> |
| | 12250 | | /// The entity model ID. |
| | 12251 | | /// </param> |
| | 12252 | | /// <param name='entityRoleCreateObject'> |
| | 12253 | | /// An entity role object containing the name of role. |
| | 12254 | | /// </param> |
| | 12255 | | /// <param name='customHeaders'> |
| | 12256 | | /// Headers that will be added to request. |
| | 12257 | | /// </param> |
| | 12258 | | /// <param name='cancellationToken'> |
| | 12259 | | /// The cancellation token. |
| | 12260 | | /// </param> |
| | 12261 | | /// <exception cref="ErrorResponseException"> |
| | 12262 | | /// Thrown when the operation returned an invalid status code |
| | 12263 | | /// </exception> |
| | 12264 | | /// <exception cref="SerializationException"> |
| | 12265 | | /// Thrown when unable to deserialize the response |
| | 12266 | | /// </exception> |
| | 12267 | | /// <exception cref="ValidationException"> |
| | 12268 | | /// Thrown when a required parameter is null |
| | 12269 | | /// </exception> |
| | 12270 | | /// <exception cref="System.ArgumentNullException"> |
| | 12271 | | /// Thrown when a required parameter is null |
| | 12272 | | /// </exception> |
| | 12273 | | /// <return> |
| | 12274 | | /// A response object containing the response body and response headers. |
| | 12275 | | /// </return> |
| | 12276 | | public async Task<HttpOperationResponse<System.Guid>> CreatePatternAnyEntityRoleWithHttpMessagesAsync(System.Gui |
| | 12277 | | { |
| 5 | 12278 | | if (Client.Endpoint == null) |
| | 12279 | | { |
| 0 | 12280 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 12281 | | } |
| 5 | 12282 | | if (versionId == null) |
| | 12283 | | { |
| 0 | 12284 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 12285 | | } |
| 5 | 12286 | | if (entityRoleCreateObject == null) |
| | 12287 | | { |
| 0 | 12288 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject"); |
| | 12289 | | } |
| | 12290 | | // Tracing |
| 5 | 12291 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 5 | 12292 | | string _invocationId = null; |
| 5 | 12293 | | if (_shouldTrace) |
| | 12294 | | { |
| 0 | 12295 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 12296 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 12297 | | tracingParameters.Add("appId", appId); |
| 0 | 12298 | | tracingParameters.Add("versionId", versionId); |
| 0 | 12299 | | tracingParameters.Add("entityId", entityId); |
| 0 | 12300 | | tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject); |
| 0 | 12301 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 12302 | | ServiceClientTracing.Enter(_invocationId, this, "CreatePatternAnyEntityRole", tracingParameters); |
| | 12303 | | } |
| | 12304 | | // Construct URL |
| 5 | 12305 | | var _baseUrl = Client.BaseUri; |
| 5 | 12306 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 5 | 12307 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 5 | 12308 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 5 | 12309 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 5 | 12310 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 12311 | | // Create HTTP transport objects |
| 5 | 12312 | | var _httpRequest = new HttpRequestMessage(); |
| 5 | 12313 | | HttpResponseMessage _httpResponse = null; |
| 5 | 12314 | | _httpRequest.Method = new HttpMethod("POST"); |
| 5 | 12315 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 12316 | | // Set Headers |
| | 12317 | |
|
| | 12318 | |
|
| 5 | 12319 | | if (customHeaders != null) |
| | 12320 | | { |
| 0 | 12321 | | foreach(var _header in customHeaders) |
| | 12322 | | { |
| 0 | 12323 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 12324 | | { |
| 0 | 12325 | | _httpRequest.Headers.Remove(_header.Key); |
| | 12326 | | } |
| 0 | 12327 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 12328 | | } |
| | 12329 | | } |
| | 12330 | |
|
| | 12331 | | // Serialize Request |
| 5 | 12332 | | string _requestContent = null; |
| 5 | 12333 | | if(entityRoleCreateObject != null) |
| | 12334 | | { |
| 5 | 12335 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri |
| 5 | 12336 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 5 | 12337 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 12338 | | } |
| | 12339 | | // Set Credentials |
| 5 | 12340 | | if (Client.Credentials != null) |
| | 12341 | | { |
| 5 | 12342 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 12343 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 12344 | | } |
| | 12345 | | // Send Request |
| 5 | 12346 | | if (_shouldTrace) |
| | 12347 | | { |
| 0 | 12348 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 12349 | | } |
| 5 | 12350 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 12351 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 5 | 12352 | | if (_shouldTrace) |
| | 12353 | | { |
| 0 | 12354 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 12355 | | } |
| 5 | 12356 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 5 | 12357 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 12358 | | string _responseContent = null; |
| 5 | 12359 | | if ((int)_statusCode != 201) |
| | 12360 | | { |
| 0 | 12361 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 12362 | | try |
| | 12363 | | { |
| 0 | 12364 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 12365 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 12366 | | if (_errorBody != null) |
| | 12367 | | { |
| 0 | 12368 | | ex.Body = _errorBody; |
| | 12369 | | } |
| 0 | 12370 | | } |
| 0 | 12371 | | catch (JsonException) |
| | 12372 | | { |
| | 12373 | | // Ignore the exception |
| 0 | 12374 | | } |
| 0 | 12375 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 12376 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 12377 | | if (_shouldTrace) |
| | 12378 | | { |
| 0 | 12379 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 12380 | | } |
| 0 | 12381 | | _httpRequest.Dispose(); |
| 0 | 12382 | | if (_httpResponse != null) |
| | 12383 | | { |
| 0 | 12384 | | _httpResponse.Dispose(); |
| | 12385 | | } |
| 0 | 12386 | | throw ex; |
| | 12387 | | } |
| | 12388 | | // Create Result |
| 5 | 12389 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 5 | 12390 | | _result.Request = _httpRequest; |
| 5 | 12391 | | _result.Response = _httpResponse; |
| | 12392 | | // Deserialize Response |
| 5 | 12393 | | if ((int)_statusCode == 201) |
| | 12394 | | { |
| 5 | 12395 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 12396 | | try |
| | 12397 | | { |
| 5 | 12398 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 5 | 12399 | | } |
| 0 | 12400 | | catch (JsonException ex) |
| | 12401 | | { |
| 0 | 12402 | | _httpRequest.Dispose(); |
| 0 | 12403 | | if (_httpResponse != null) |
| | 12404 | | { |
| 0 | 12405 | | _httpResponse.Dispose(); |
| | 12406 | | } |
| 0 | 12407 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 12408 | | } |
| | 12409 | | } |
| 5 | 12410 | | if (_shouldTrace) |
| | 12411 | | { |
| 0 | 12412 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 12413 | | } |
| 5 | 12414 | | return _result; |
| 5 | 12415 | | } |
| | 12416 | |
|
| | 12417 | | /// <summary> |
| | 12418 | | /// Get all roles for a hierarchical entity in a version of the application |
| | 12419 | | /// </summary> |
| | 12420 | | /// <param name='appId'> |
| | 12421 | | /// The application ID. |
| | 12422 | | /// </param> |
| | 12423 | | /// <param name='versionId'> |
| | 12424 | | /// The version ID. |
| | 12425 | | /// </param> |
| | 12426 | | /// <param name='hEntityId'> |
| | 12427 | | /// The hierarchical entity extractor ID. |
| | 12428 | | /// </param> |
| | 12429 | | /// <param name='customHeaders'> |
| | 12430 | | /// Headers that will be added to request. |
| | 12431 | | /// </param> |
| | 12432 | | /// <param name='cancellationToken'> |
| | 12433 | | /// The cancellation token. |
| | 12434 | | /// </param> |
| | 12435 | | /// <exception cref="ErrorResponseException"> |
| | 12436 | | /// Thrown when the operation returned an invalid status code |
| | 12437 | | /// </exception> |
| | 12438 | | /// <exception cref="SerializationException"> |
| | 12439 | | /// Thrown when unable to deserialize the response |
| | 12440 | | /// </exception> |
| | 12441 | | /// <exception cref="ValidationException"> |
| | 12442 | | /// Thrown when a required parameter is null |
| | 12443 | | /// </exception> |
| | 12444 | | /// <exception cref="System.ArgumentNullException"> |
| | 12445 | | /// Thrown when a required parameter is null |
| | 12446 | | /// </exception> |
| | 12447 | | /// <return> |
| | 12448 | | /// A response object containing the response body and response headers. |
| | 12449 | | /// </return> |
| | 12450 | | public async Task<HttpOperationResponse<IList<EntityRole>>> ListHierarchicalEntityRolesWithHttpMessagesAsync(Sys |
| | 12451 | | { |
| 0 | 12452 | | if (Client.Endpoint == null) |
| | 12453 | | { |
| 0 | 12454 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 12455 | | } |
| 0 | 12456 | | if (versionId == null) |
| | 12457 | | { |
| 0 | 12458 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 12459 | | } |
| | 12460 | | // Tracing |
| 0 | 12461 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 12462 | | string _invocationId = null; |
| 0 | 12463 | | if (_shouldTrace) |
| | 12464 | | { |
| 0 | 12465 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 12466 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 12467 | | tracingParameters.Add("appId", appId); |
| 0 | 12468 | | tracingParameters.Add("versionId", versionId); |
| 0 | 12469 | | tracingParameters.Add("hEntityId", hEntityId); |
| 0 | 12470 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 12471 | | ServiceClientTracing.Enter(_invocationId, this, "ListHierarchicalEntityRoles", tracingParameters); |
| | 12472 | | } |
| | 12473 | | // Construct URL |
| 0 | 12474 | | var _baseUrl = Client.BaseUri; |
| 0 | 12475 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale |
| 0 | 12476 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 12477 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 12478 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 12479 | | _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| | 12480 | | // Create HTTP transport objects |
| 0 | 12481 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 12482 | | HttpResponseMessage _httpResponse = null; |
| 0 | 12483 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 12484 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 12485 | | // Set Headers |
| | 12486 | |
|
| | 12487 | |
|
| 0 | 12488 | | if (customHeaders != null) |
| | 12489 | | { |
| 0 | 12490 | | foreach(var _header in customHeaders) |
| | 12491 | | { |
| 0 | 12492 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 12493 | | { |
| 0 | 12494 | | _httpRequest.Headers.Remove(_header.Key); |
| | 12495 | | } |
| 0 | 12496 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 12497 | | } |
| | 12498 | | } |
| | 12499 | |
|
| | 12500 | | // Serialize Request |
| 0 | 12501 | | string _requestContent = null; |
| | 12502 | | // Set Credentials |
| 0 | 12503 | | if (Client.Credentials != null) |
| | 12504 | | { |
| 0 | 12505 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 12506 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 12507 | | } |
| | 12508 | | // Send Request |
| 0 | 12509 | | if (_shouldTrace) |
| | 12510 | | { |
| 0 | 12511 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 12512 | | } |
| 0 | 12513 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 12514 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 12515 | | if (_shouldTrace) |
| | 12516 | | { |
| 0 | 12517 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 12518 | | } |
| 0 | 12519 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 12520 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 12521 | | string _responseContent = null; |
| 0 | 12522 | | if ((int)_statusCode != 200) |
| | 12523 | | { |
| 0 | 12524 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 12525 | | try |
| | 12526 | | { |
| 0 | 12527 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 12528 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 12529 | | if (_errorBody != null) |
| | 12530 | | { |
| 0 | 12531 | | ex.Body = _errorBody; |
| | 12532 | | } |
| 0 | 12533 | | } |
| 0 | 12534 | | catch (JsonException) |
| | 12535 | | { |
| | 12536 | | // Ignore the exception |
| 0 | 12537 | | } |
| 0 | 12538 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 12539 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 12540 | | if (_shouldTrace) |
| | 12541 | | { |
| 0 | 12542 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 12543 | | } |
| 0 | 12544 | | _httpRequest.Dispose(); |
| 0 | 12545 | | if (_httpResponse != null) |
| | 12546 | | { |
| 0 | 12547 | | _httpResponse.Dispose(); |
| | 12548 | | } |
| 0 | 12549 | | throw ex; |
| | 12550 | | } |
| | 12551 | | // Create Result |
| 0 | 12552 | | var _result = new HttpOperationResponse<IList<EntityRole>>(); |
| 0 | 12553 | | _result.Request = _httpRequest; |
| 0 | 12554 | | _result.Response = _httpResponse; |
| | 12555 | | // Deserialize Response |
| 0 | 12556 | | if ((int)_statusCode == 200) |
| | 12557 | | { |
| 0 | 12558 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 12559 | | try |
| | 12560 | | { |
| 0 | 12561 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont |
| 0 | 12562 | | } |
| 0 | 12563 | | catch (JsonException ex) |
| | 12564 | | { |
| 0 | 12565 | | _httpRequest.Dispose(); |
| 0 | 12566 | | if (_httpResponse != null) |
| | 12567 | | { |
| 0 | 12568 | | _httpResponse.Dispose(); |
| | 12569 | | } |
| 0 | 12570 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 12571 | | } |
| | 12572 | | } |
| 0 | 12573 | | if (_shouldTrace) |
| | 12574 | | { |
| 0 | 12575 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 12576 | | } |
| 0 | 12577 | | return _result; |
| 0 | 12578 | | } |
| | 12579 | |
|
| | 12580 | | /// <summary> |
| | 12581 | | /// Create a role for an hierarchical entity in a version of the application. |
| | 12582 | | /// </summary> |
| | 12583 | | /// <param name='appId'> |
| | 12584 | | /// The application ID. |
| | 12585 | | /// </param> |
| | 12586 | | /// <param name='versionId'> |
| | 12587 | | /// The version ID. |
| | 12588 | | /// </param> |
| | 12589 | | /// <param name='hEntityId'> |
| | 12590 | | /// The hierarchical entity extractor ID. |
| | 12591 | | /// </param> |
| | 12592 | | /// <param name='entityRoleCreateObject'> |
| | 12593 | | /// An entity role object containing the name of role. |
| | 12594 | | /// </param> |
| | 12595 | | /// <param name='customHeaders'> |
| | 12596 | | /// Headers that will be added to request. |
| | 12597 | | /// </param> |
| | 12598 | | /// <param name='cancellationToken'> |
| | 12599 | | /// The cancellation token. |
| | 12600 | | /// </param> |
| | 12601 | | /// <exception cref="ErrorResponseException"> |
| | 12602 | | /// Thrown when the operation returned an invalid status code |
| | 12603 | | /// </exception> |
| | 12604 | | /// <exception cref="SerializationException"> |
| | 12605 | | /// Thrown when unable to deserialize the response |
| | 12606 | | /// </exception> |
| | 12607 | | /// <exception cref="ValidationException"> |
| | 12608 | | /// Thrown when a required parameter is null |
| | 12609 | | /// </exception> |
| | 12610 | | /// <exception cref="System.ArgumentNullException"> |
| | 12611 | | /// Thrown when a required parameter is null |
| | 12612 | | /// </exception> |
| | 12613 | | /// <return> |
| | 12614 | | /// A response object containing the response body and response headers. |
| | 12615 | | /// </return> |
| | 12616 | | public async Task<HttpOperationResponse<System.Guid>> CreateHierarchicalEntityRoleWithHttpMessagesAsync(System.G |
| | 12617 | | { |
| 0 | 12618 | | if (Client.Endpoint == null) |
| | 12619 | | { |
| 0 | 12620 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 12621 | | } |
| 0 | 12622 | | if (versionId == null) |
| | 12623 | | { |
| 0 | 12624 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 12625 | | } |
| 0 | 12626 | | if (entityRoleCreateObject == null) |
| | 12627 | | { |
| 0 | 12628 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject"); |
| | 12629 | | } |
| | 12630 | | // Tracing |
| 0 | 12631 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 12632 | | string _invocationId = null; |
| 0 | 12633 | | if (_shouldTrace) |
| | 12634 | | { |
| 0 | 12635 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 12636 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 12637 | | tracingParameters.Add("appId", appId); |
| 0 | 12638 | | tracingParameters.Add("versionId", versionId); |
| 0 | 12639 | | tracingParameters.Add("hEntityId", hEntityId); |
| 0 | 12640 | | tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject); |
| 0 | 12641 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 12642 | | ServiceClientTracing.Enter(_invocationId, this, "CreateHierarchicalEntityRole", tracingParameters); |
| | 12643 | | } |
| | 12644 | | // Construct URL |
| 0 | 12645 | | var _baseUrl = Client.BaseUri; |
| 0 | 12646 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale |
| 0 | 12647 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 12648 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 12649 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 12650 | | _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| | 12651 | | // Create HTTP transport objects |
| 0 | 12652 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 12653 | | HttpResponseMessage _httpResponse = null; |
| 0 | 12654 | | _httpRequest.Method = new HttpMethod("POST"); |
| 0 | 12655 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 12656 | | // Set Headers |
| | 12657 | |
|
| | 12658 | |
|
| 0 | 12659 | | if (customHeaders != null) |
| | 12660 | | { |
| 0 | 12661 | | foreach(var _header in customHeaders) |
| | 12662 | | { |
| 0 | 12663 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 12664 | | { |
| 0 | 12665 | | _httpRequest.Headers.Remove(_header.Key); |
| | 12666 | | } |
| 0 | 12667 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 12668 | | } |
| | 12669 | | } |
| | 12670 | |
|
| | 12671 | | // Serialize Request |
| 0 | 12672 | | string _requestContent = null; |
| 0 | 12673 | | if(entityRoleCreateObject != null) |
| | 12674 | | { |
| 0 | 12675 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri |
| 0 | 12676 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 12677 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 12678 | | } |
| | 12679 | | // Set Credentials |
| 0 | 12680 | | if (Client.Credentials != null) |
| | 12681 | | { |
| 0 | 12682 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 12683 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 12684 | | } |
| | 12685 | | // Send Request |
| 0 | 12686 | | if (_shouldTrace) |
| | 12687 | | { |
| 0 | 12688 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 12689 | | } |
| 0 | 12690 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 12691 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 12692 | | if (_shouldTrace) |
| | 12693 | | { |
| 0 | 12694 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 12695 | | } |
| 0 | 12696 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 12697 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 12698 | | string _responseContent = null; |
| 0 | 12699 | | if ((int)_statusCode != 201) |
| | 12700 | | { |
| 0 | 12701 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 12702 | | try |
| | 12703 | | { |
| 0 | 12704 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 12705 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 12706 | | if (_errorBody != null) |
| | 12707 | | { |
| 0 | 12708 | | ex.Body = _errorBody; |
| | 12709 | | } |
| 0 | 12710 | | } |
| 0 | 12711 | | catch (JsonException) |
| | 12712 | | { |
| | 12713 | | // Ignore the exception |
| 0 | 12714 | | } |
| 0 | 12715 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 12716 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 12717 | | if (_shouldTrace) |
| | 12718 | | { |
| 0 | 12719 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 12720 | | } |
| 0 | 12721 | | _httpRequest.Dispose(); |
| 0 | 12722 | | if (_httpResponse != null) |
| | 12723 | | { |
| 0 | 12724 | | _httpResponse.Dispose(); |
| | 12725 | | } |
| 0 | 12726 | | throw ex; |
| | 12727 | | } |
| | 12728 | | // Create Result |
| 0 | 12729 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 0 | 12730 | | _result.Request = _httpRequest; |
| 0 | 12731 | | _result.Response = _httpResponse; |
| | 12732 | | // Deserialize Response |
| 0 | 12733 | | if ((int)_statusCode == 201) |
| | 12734 | | { |
| 0 | 12735 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 12736 | | try |
| | 12737 | | { |
| 0 | 12738 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 0 | 12739 | | } |
| 0 | 12740 | | catch (JsonException ex) |
| | 12741 | | { |
| 0 | 12742 | | _httpRequest.Dispose(); |
| 0 | 12743 | | if (_httpResponse != null) |
| | 12744 | | { |
| 0 | 12745 | | _httpResponse.Dispose(); |
| | 12746 | | } |
| 0 | 12747 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 12748 | | } |
| | 12749 | | } |
| 0 | 12750 | | if (_shouldTrace) |
| | 12751 | | { |
| 0 | 12752 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 12753 | | } |
| 0 | 12754 | | return _result; |
| 0 | 12755 | | } |
| | 12756 | |
|
| | 12757 | | /// <summary> |
| | 12758 | | /// Get all roles for a prebuilt entity in a version of the application |
| | 12759 | | /// </summary> |
| | 12760 | | /// <param name='appId'> |
| | 12761 | | /// The application ID. |
| | 12762 | | /// </param> |
| | 12763 | | /// <param name='versionId'> |
| | 12764 | | /// The version ID. |
| | 12765 | | /// </param> |
| | 12766 | | /// <param name='entityId'> |
| | 12767 | | /// entity Id |
| | 12768 | | /// </param> |
| | 12769 | | /// <param name='customHeaders'> |
| | 12770 | | /// Headers that will be added to request. |
| | 12771 | | /// </param> |
| | 12772 | | /// <param name='cancellationToken'> |
| | 12773 | | /// The cancellation token. |
| | 12774 | | /// </param> |
| | 12775 | | /// <exception cref="ErrorResponseException"> |
| | 12776 | | /// Thrown when the operation returned an invalid status code |
| | 12777 | | /// </exception> |
| | 12778 | | /// <exception cref="SerializationException"> |
| | 12779 | | /// Thrown when unable to deserialize the response |
| | 12780 | | /// </exception> |
| | 12781 | | /// <exception cref="ValidationException"> |
| | 12782 | | /// Thrown when a required parameter is null |
| | 12783 | | /// </exception> |
| | 12784 | | /// <exception cref="System.ArgumentNullException"> |
| | 12785 | | /// Thrown when a required parameter is null |
| | 12786 | | /// </exception> |
| | 12787 | | /// <return> |
| | 12788 | | /// A response object containing the response body and response headers. |
| | 12789 | | /// </return> |
| | 12790 | | public async Task<HttpOperationResponse<IList<EntityRole>>> ListCustomPrebuiltEntityRolesWithHttpMessagesAsync(S |
| | 12791 | | { |
| 3 | 12792 | | if (Client.Endpoint == null) |
| | 12793 | | { |
| 0 | 12794 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 12795 | | } |
| 3 | 12796 | | if (versionId == null) |
| | 12797 | | { |
| 0 | 12798 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 12799 | | } |
| | 12800 | | // Tracing |
| 3 | 12801 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 3 | 12802 | | string _invocationId = null; |
| 3 | 12803 | | if (_shouldTrace) |
| | 12804 | | { |
| 0 | 12805 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 12806 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 12807 | | tracingParameters.Add("appId", appId); |
| 0 | 12808 | | tracingParameters.Add("versionId", versionId); |
| 0 | 12809 | | tracingParameters.Add("entityId", entityId); |
| 0 | 12810 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 12811 | | ServiceClientTracing.Enter(_invocationId, this, "ListCustomPrebuiltEntityRoles", tracingParameters); |
| | 12812 | | } |
| | 12813 | | // Construct URL |
| 3 | 12814 | | var _baseUrl = Client.BaseUri; |
| 3 | 12815 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil |
| 3 | 12816 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 3 | 12817 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 3 | 12818 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 3 | 12819 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 12820 | | // Create HTTP transport objects |
| 3 | 12821 | | var _httpRequest = new HttpRequestMessage(); |
| 3 | 12822 | | HttpResponseMessage _httpResponse = null; |
| 3 | 12823 | | _httpRequest.Method = new HttpMethod("GET"); |
| 3 | 12824 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 12825 | | // Set Headers |
| | 12826 | |
|
| | 12827 | |
|
| 3 | 12828 | | if (customHeaders != null) |
| | 12829 | | { |
| 0 | 12830 | | foreach(var _header in customHeaders) |
| | 12831 | | { |
| 0 | 12832 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 12833 | | { |
| 0 | 12834 | | _httpRequest.Headers.Remove(_header.Key); |
| | 12835 | | } |
| 0 | 12836 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 12837 | | } |
| | 12838 | | } |
| | 12839 | |
|
| | 12840 | | // Serialize Request |
| 3 | 12841 | | string _requestContent = null; |
| | 12842 | | // Set Credentials |
| 3 | 12843 | | if (Client.Credentials != null) |
| | 12844 | | { |
| 3 | 12845 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 12846 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 12847 | | } |
| | 12848 | | // Send Request |
| 3 | 12849 | | if (_shouldTrace) |
| | 12850 | | { |
| 0 | 12851 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 12852 | | } |
| 3 | 12853 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 12854 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 3 | 12855 | | if (_shouldTrace) |
| | 12856 | | { |
| 0 | 12857 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 12858 | | } |
| 3 | 12859 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 3 | 12860 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 12861 | | string _responseContent = null; |
| 3 | 12862 | | if ((int)_statusCode != 200) |
| | 12863 | | { |
| 0 | 12864 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 12865 | | try |
| | 12866 | | { |
| 0 | 12867 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 12868 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 12869 | | if (_errorBody != null) |
| | 12870 | | { |
| 0 | 12871 | | ex.Body = _errorBody; |
| | 12872 | | } |
| 0 | 12873 | | } |
| 0 | 12874 | | catch (JsonException) |
| | 12875 | | { |
| | 12876 | | // Ignore the exception |
| 0 | 12877 | | } |
| 0 | 12878 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 12879 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 12880 | | if (_shouldTrace) |
| | 12881 | | { |
| 0 | 12882 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 12883 | | } |
| 0 | 12884 | | _httpRequest.Dispose(); |
| 0 | 12885 | | if (_httpResponse != null) |
| | 12886 | | { |
| 0 | 12887 | | _httpResponse.Dispose(); |
| | 12888 | | } |
| 0 | 12889 | | throw ex; |
| | 12890 | | } |
| | 12891 | | // Create Result |
| 3 | 12892 | | var _result = new HttpOperationResponse<IList<EntityRole>>(); |
| 3 | 12893 | | _result.Request = _httpRequest; |
| 3 | 12894 | | _result.Response = _httpResponse; |
| | 12895 | | // Deserialize Response |
| 3 | 12896 | | if ((int)_statusCode == 200) |
| | 12897 | | { |
| 3 | 12898 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 12899 | | try |
| | 12900 | | { |
| 3 | 12901 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<EntityRole>>(_responseCont |
| 3 | 12902 | | } |
| 0 | 12903 | | catch (JsonException ex) |
| | 12904 | | { |
| 0 | 12905 | | _httpRequest.Dispose(); |
| 0 | 12906 | | if (_httpResponse != null) |
| | 12907 | | { |
| 0 | 12908 | | _httpResponse.Dispose(); |
| | 12909 | | } |
| 0 | 12910 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 12911 | | } |
| | 12912 | | } |
| 3 | 12913 | | if (_shouldTrace) |
| | 12914 | | { |
| 0 | 12915 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 12916 | | } |
| 3 | 12917 | | return _result; |
| 3 | 12918 | | } |
| | 12919 | |
|
| | 12920 | | /// <summary> |
| | 12921 | | /// Create a role for a prebuilt entity in a version of the application. |
| | 12922 | | /// </summary> |
| | 12923 | | /// <param name='appId'> |
| | 12924 | | /// The application ID. |
| | 12925 | | /// </param> |
| | 12926 | | /// <param name='versionId'> |
| | 12927 | | /// The version ID. |
| | 12928 | | /// </param> |
| | 12929 | | /// <param name='entityId'> |
| | 12930 | | /// The entity model ID. |
| | 12931 | | /// </param> |
| | 12932 | | /// <param name='entityRoleCreateObject'> |
| | 12933 | | /// An entity role object containing the name of role. |
| | 12934 | | /// </param> |
| | 12935 | | /// <param name='customHeaders'> |
| | 12936 | | /// Headers that will be added to request. |
| | 12937 | | /// </param> |
| | 12938 | | /// <param name='cancellationToken'> |
| | 12939 | | /// The cancellation token. |
| | 12940 | | /// </param> |
| | 12941 | | /// <exception cref="ErrorResponseException"> |
| | 12942 | | /// Thrown when the operation returned an invalid status code |
| | 12943 | | /// </exception> |
| | 12944 | | /// <exception cref="SerializationException"> |
| | 12945 | | /// Thrown when unable to deserialize the response |
| | 12946 | | /// </exception> |
| | 12947 | | /// <exception cref="ValidationException"> |
| | 12948 | | /// Thrown when a required parameter is null |
| | 12949 | | /// </exception> |
| | 12950 | | /// <exception cref="System.ArgumentNullException"> |
| | 12951 | | /// Thrown when a required parameter is null |
| | 12952 | | /// </exception> |
| | 12953 | | /// <return> |
| | 12954 | | /// A response object containing the response body and response headers. |
| | 12955 | | /// </return> |
| | 12956 | | public async Task<HttpOperationResponse<System.Guid>> CreateCustomPrebuiltEntityRoleWithHttpMessagesAsync(System |
| | 12957 | | { |
| 5 | 12958 | | if (Client.Endpoint == null) |
| | 12959 | | { |
| 0 | 12960 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 12961 | | } |
| 5 | 12962 | | if (versionId == null) |
| | 12963 | | { |
| 0 | 12964 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 12965 | | } |
| 5 | 12966 | | if (entityRoleCreateObject == null) |
| | 12967 | | { |
| 0 | 12968 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleCreateObject"); |
| | 12969 | | } |
| | 12970 | | // Tracing |
| 5 | 12971 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 5 | 12972 | | string _invocationId = null; |
| 5 | 12973 | | if (_shouldTrace) |
| | 12974 | | { |
| 0 | 12975 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 12976 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 12977 | | tracingParameters.Add("appId", appId); |
| 0 | 12978 | | tracingParameters.Add("versionId", versionId); |
| 0 | 12979 | | tracingParameters.Add("entityId", entityId); |
| 0 | 12980 | | tracingParameters.Add("entityRoleCreateObject", entityRoleCreateObject); |
| 0 | 12981 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 12982 | | ServiceClientTracing.Enter(_invocationId, this, "CreateCustomPrebuiltEntityRole", tracingParameters); |
| | 12983 | | } |
| | 12984 | | // Construct URL |
| 5 | 12985 | | var _baseUrl = Client.BaseUri; |
| 5 | 12986 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil |
| 5 | 12987 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 5 | 12988 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 5 | 12989 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 5 | 12990 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 12991 | | // Create HTTP transport objects |
| 5 | 12992 | | var _httpRequest = new HttpRequestMessage(); |
| 5 | 12993 | | HttpResponseMessage _httpResponse = null; |
| 5 | 12994 | | _httpRequest.Method = new HttpMethod("POST"); |
| 5 | 12995 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 12996 | | // Set Headers |
| | 12997 | |
|
| | 12998 | |
|
| 5 | 12999 | | if (customHeaders != null) |
| | 13000 | | { |
| 0 | 13001 | | foreach(var _header in customHeaders) |
| | 13002 | | { |
| 0 | 13003 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 13004 | | { |
| 0 | 13005 | | _httpRequest.Headers.Remove(_header.Key); |
| | 13006 | | } |
| 0 | 13007 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 13008 | | } |
| | 13009 | | } |
| | 13010 | |
|
| | 13011 | | // Serialize Request |
| 5 | 13012 | | string _requestContent = null; |
| 5 | 13013 | | if(entityRoleCreateObject != null) |
| | 13014 | | { |
| 5 | 13015 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleCreateObject, Client.Seri |
| 5 | 13016 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 5 | 13017 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 13018 | | } |
| | 13019 | | // Set Credentials |
| 5 | 13020 | | if (Client.Credentials != null) |
| | 13021 | | { |
| 5 | 13022 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 13023 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 13024 | | } |
| | 13025 | | // Send Request |
| 5 | 13026 | | if (_shouldTrace) |
| | 13027 | | { |
| 0 | 13028 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 13029 | | } |
| 5 | 13030 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 13031 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 5 | 13032 | | if (_shouldTrace) |
| | 13033 | | { |
| 0 | 13034 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 13035 | | } |
| 5 | 13036 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 5 | 13037 | | cancellationToken.ThrowIfCancellationRequested(); |
| 5 | 13038 | | string _responseContent = null; |
| 5 | 13039 | | if ((int)_statusCode != 201) |
| | 13040 | | { |
| 0 | 13041 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 13042 | | try |
| | 13043 | | { |
| 0 | 13044 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 13045 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 13046 | | if (_errorBody != null) |
| | 13047 | | { |
| 0 | 13048 | | ex.Body = _errorBody; |
| | 13049 | | } |
| 0 | 13050 | | } |
| 0 | 13051 | | catch (JsonException) |
| | 13052 | | { |
| | 13053 | | // Ignore the exception |
| 0 | 13054 | | } |
| 0 | 13055 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 13056 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 13057 | | if (_shouldTrace) |
| | 13058 | | { |
| 0 | 13059 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 13060 | | } |
| 0 | 13061 | | _httpRequest.Dispose(); |
| 0 | 13062 | | if (_httpResponse != null) |
| | 13063 | | { |
| 0 | 13064 | | _httpResponse.Dispose(); |
| | 13065 | | } |
| 0 | 13066 | | throw ex; |
| | 13067 | | } |
| | 13068 | | // Create Result |
| 5 | 13069 | | var _result = new HttpOperationResponse<System.Guid>(); |
| 5 | 13070 | | _result.Request = _httpRequest; |
| 5 | 13071 | | _result.Response = _httpResponse; |
| | 13072 | | // Deserialize Response |
| 5 | 13073 | | if ((int)_statusCode == 201) |
| | 13074 | | { |
| 5 | 13075 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 13076 | | try |
| | 13077 | | { |
| 5 | 13078 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<System.Guid>(_responseContent, C |
| 5 | 13079 | | } |
| 0 | 13080 | | catch (JsonException ex) |
| | 13081 | | { |
| 0 | 13082 | | _httpRequest.Dispose(); |
| 0 | 13083 | | if (_httpResponse != null) |
| | 13084 | | { |
| 0 | 13085 | | _httpResponse.Dispose(); |
| | 13086 | | } |
| 0 | 13087 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 13088 | | } |
| | 13089 | | } |
| 5 | 13090 | | if (_shouldTrace) |
| | 13091 | | { |
| 0 | 13092 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 13093 | | } |
| 5 | 13094 | | return _result; |
| 5 | 13095 | | } |
| | 13096 | |
|
| | 13097 | | /// <summary> |
| | 13098 | | /// Get the explicit (exception) list of the pattern.any entity in a version of |
| | 13099 | | /// the application. |
| | 13100 | | /// </summary> |
| | 13101 | | /// <param name='appId'> |
| | 13102 | | /// The application ID. |
| | 13103 | | /// </param> |
| | 13104 | | /// <param name='versionId'> |
| | 13105 | | /// The version ID. |
| | 13106 | | /// </param> |
| | 13107 | | /// <param name='entityId'> |
| | 13108 | | /// The Pattern.Any entity id. |
| | 13109 | | /// </param> |
| | 13110 | | /// <param name='customHeaders'> |
| | 13111 | | /// Headers that will be added to request. |
| | 13112 | | /// </param> |
| | 13113 | | /// <param name='cancellationToken'> |
| | 13114 | | /// The cancellation token. |
| | 13115 | | /// </param> |
| | 13116 | | /// <exception cref="ErrorResponseException"> |
| | 13117 | | /// Thrown when the operation returned an invalid status code |
| | 13118 | | /// </exception> |
| | 13119 | | /// <exception cref="SerializationException"> |
| | 13120 | | /// Thrown when unable to deserialize the response |
| | 13121 | | /// </exception> |
| | 13122 | | /// <exception cref="ValidationException"> |
| | 13123 | | /// Thrown when a required parameter is null |
| | 13124 | | /// </exception> |
| | 13125 | | /// <exception cref="System.ArgumentNullException"> |
| | 13126 | | /// Thrown when a required parameter is null |
| | 13127 | | /// </exception> |
| | 13128 | | /// <return> |
| | 13129 | | /// A response object containing the response body and response headers. |
| | 13130 | | /// </return> |
| | 13131 | | public async Task<HttpOperationResponse<IList<ExplicitListItem>>> GetExplicitListWithHttpMessagesAsync(System.Gu |
| | 13132 | | { |
| 2 | 13133 | | if (Client.Endpoint == null) |
| | 13134 | | { |
| 0 | 13135 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 13136 | | } |
| 2 | 13137 | | if (versionId == null) |
| | 13138 | | { |
| 0 | 13139 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 13140 | | } |
| | 13141 | | // Tracing |
| 2 | 13142 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 13143 | | string _invocationId = null; |
| 2 | 13144 | | if (_shouldTrace) |
| | 13145 | | { |
| 0 | 13146 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 13147 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 13148 | | tracingParameters.Add("appId", appId); |
| 0 | 13149 | | tracingParameters.Add("versionId", versionId); |
| 0 | 13150 | | tracingParameters.Add("entityId", entityId); |
| 0 | 13151 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 13152 | | ServiceClientTracing.Enter(_invocationId, this, "GetExplicitList", tracingParameters); |
| | 13153 | | } |
| | 13154 | | // Construct URL |
| 2 | 13155 | | var _baseUrl = Client.BaseUri; |
| 2 | 13156 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 2 | 13157 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 13158 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 13159 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 2 | 13160 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 13161 | | // Create HTTP transport objects |
| 2 | 13162 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 13163 | | HttpResponseMessage _httpResponse = null; |
| 2 | 13164 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 13165 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 13166 | | // Set Headers |
| | 13167 | |
|
| | 13168 | |
|
| 2 | 13169 | | if (customHeaders != null) |
| | 13170 | | { |
| 0 | 13171 | | foreach(var _header in customHeaders) |
| | 13172 | | { |
| 0 | 13173 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 13174 | | { |
| 0 | 13175 | | _httpRequest.Headers.Remove(_header.Key); |
| | 13176 | | } |
| 0 | 13177 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 13178 | | } |
| | 13179 | | } |
| | 13180 | |
|
| | 13181 | | // Serialize Request |
| 2 | 13182 | | string _requestContent = null; |
| | 13183 | | // Set Credentials |
| 2 | 13184 | | if (Client.Credentials != null) |
| | 13185 | | { |
| 2 | 13186 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 13187 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 13188 | | } |
| | 13189 | | // Send Request |
| 2 | 13190 | | if (_shouldTrace) |
| | 13191 | | { |
| 0 | 13192 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 13193 | | } |
| 2 | 13194 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 13195 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 13196 | | if (_shouldTrace) |
| | 13197 | | { |
| 0 | 13198 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 13199 | | } |
| 2 | 13200 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 13201 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 13202 | | string _responseContent = null; |
| 2 | 13203 | | if ((int)_statusCode != 200) |
| | 13204 | | { |
| 0 | 13205 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 13206 | | try |
| | 13207 | | { |
| 0 | 13208 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 13209 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 13210 | | if (_errorBody != null) |
| | 13211 | | { |
| 0 | 13212 | | ex.Body = _errorBody; |
| | 13213 | | } |
| 0 | 13214 | | } |
| 0 | 13215 | | catch (JsonException) |
| | 13216 | | { |
| | 13217 | | // Ignore the exception |
| 0 | 13218 | | } |
| 0 | 13219 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 13220 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 13221 | | if (_shouldTrace) |
| | 13222 | | { |
| 0 | 13223 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 13224 | | } |
| 0 | 13225 | | _httpRequest.Dispose(); |
| 0 | 13226 | | if (_httpResponse != null) |
| | 13227 | | { |
| 0 | 13228 | | _httpResponse.Dispose(); |
| | 13229 | | } |
| 0 | 13230 | | throw ex; |
| | 13231 | | } |
| | 13232 | | // Create Result |
| 2 | 13233 | | var _result = new HttpOperationResponse<IList<ExplicitListItem>>(); |
| 2 | 13234 | | _result.Request = _httpRequest; |
| 2 | 13235 | | _result.Response = _httpResponse; |
| | 13236 | | // Deserialize Response |
| 2 | 13237 | | if ((int)_statusCode == 200) |
| | 13238 | | { |
| 2 | 13239 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 13240 | | try |
| | 13241 | | { |
| 2 | 13242 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<IList<ExplicitListItem>>(_respon |
| 2 | 13243 | | } |
| 0 | 13244 | | catch (JsonException ex) |
| | 13245 | | { |
| 0 | 13246 | | _httpRequest.Dispose(); |
| 0 | 13247 | | if (_httpResponse != null) |
| | 13248 | | { |
| 0 | 13249 | | _httpResponse.Dispose(); |
| | 13250 | | } |
| 0 | 13251 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 13252 | | } |
| | 13253 | | } |
| 2 | 13254 | | if (_shouldTrace) |
| | 13255 | | { |
| 0 | 13256 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 13257 | | } |
| 2 | 13258 | | return _result; |
| 2 | 13259 | | } |
| | 13260 | |
|
| | 13261 | | /// <summary> |
| | 13262 | | /// Add a new exception to the explicit list for the Pattern.Any entity in a |
| | 13263 | | /// version of the application. |
| | 13264 | | /// </summary> |
| | 13265 | | /// <param name='appId'> |
| | 13266 | | /// The application ID. |
| | 13267 | | /// </param> |
| | 13268 | | /// <param name='versionId'> |
| | 13269 | | /// The version ID. |
| | 13270 | | /// </param> |
| | 13271 | | /// <param name='entityId'> |
| | 13272 | | /// The Pattern.Any entity extractor ID. |
| | 13273 | | /// </param> |
| | 13274 | | /// <param name='item'> |
| | 13275 | | /// The new explicit list item. |
| | 13276 | | /// </param> |
| | 13277 | | /// <param name='customHeaders'> |
| | 13278 | | /// Headers that will be added to request. |
| | 13279 | | /// </param> |
| | 13280 | | /// <param name='cancellationToken'> |
| | 13281 | | /// The cancellation token. |
| | 13282 | | /// </param> |
| | 13283 | | /// <exception cref="ErrorResponseException"> |
| | 13284 | | /// Thrown when the operation returned an invalid status code |
| | 13285 | | /// </exception> |
| | 13286 | | /// <exception cref="SerializationException"> |
| | 13287 | | /// Thrown when unable to deserialize the response |
| | 13288 | | /// </exception> |
| | 13289 | | /// <exception cref="ValidationException"> |
| | 13290 | | /// Thrown when a required parameter is null |
| | 13291 | | /// </exception> |
| | 13292 | | /// <exception cref="System.ArgumentNullException"> |
| | 13293 | | /// Thrown when a required parameter is null |
| | 13294 | | /// </exception> |
| | 13295 | | /// <return> |
| | 13296 | | /// A response object containing the response body and response headers. |
| | 13297 | | /// </return> |
| | 13298 | | public async Task<HttpOperationResponse<int?>> AddExplicitListItemWithHttpMessagesAsync(System.Guid appId, strin |
| | 13299 | | { |
| 4 | 13300 | | if (Client.Endpoint == null) |
| | 13301 | | { |
| 0 | 13302 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 13303 | | } |
| 4 | 13304 | | if (versionId == null) |
| | 13305 | | { |
| 0 | 13306 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 13307 | | } |
| 4 | 13308 | | if (item == null) |
| | 13309 | | { |
| 0 | 13310 | | throw new ValidationException(ValidationRules.CannotBeNull, "item"); |
| | 13311 | | } |
| | 13312 | | // Tracing |
| 4 | 13313 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 4 | 13314 | | string _invocationId = null; |
| 4 | 13315 | | if (_shouldTrace) |
| | 13316 | | { |
| 0 | 13317 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 13318 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 13319 | | tracingParameters.Add("appId", appId); |
| 0 | 13320 | | tracingParameters.Add("versionId", versionId); |
| 0 | 13321 | | tracingParameters.Add("entityId", entityId); |
| 0 | 13322 | | tracingParameters.Add("item", item); |
| 0 | 13323 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 13324 | | ServiceClientTracing.Enter(_invocationId, this, "AddExplicitListItem", tracingParameters); |
| | 13325 | | } |
| | 13326 | | // Construct URL |
| 4 | 13327 | | var _baseUrl = Client.BaseUri; |
| 4 | 13328 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 4 | 13329 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 4 | 13330 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 4 | 13331 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 4 | 13332 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 13333 | | // Create HTTP transport objects |
| 4 | 13334 | | var _httpRequest = new HttpRequestMessage(); |
| 4 | 13335 | | HttpResponseMessage _httpResponse = null; |
| 4 | 13336 | | _httpRequest.Method = new HttpMethod("POST"); |
| 4 | 13337 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 13338 | | // Set Headers |
| | 13339 | |
|
| | 13340 | |
|
| 4 | 13341 | | if (customHeaders != null) |
| | 13342 | | { |
| 0 | 13343 | | foreach(var _header in customHeaders) |
| | 13344 | | { |
| 0 | 13345 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 13346 | | { |
| 0 | 13347 | | _httpRequest.Headers.Remove(_header.Key); |
| | 13348 | | } |
| 0 | 13349 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 13350 | | } |
| | 13351 | | } |
| | 13352 | |
|
| | 13353 | | // Serialize Request |
| 4 | 13354 | | string _requestContent = null; |
| 4 | 13355 | | if(item != null) |
| | 13356 | | { |
| 4 | 13357 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(item, Client.SerializationSettings) |
| 4 | 13358 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 4 | 13359 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 13360 | | } |
| | 13361 | | // Set Credentials |
| 4 | 13362 | | if (Client.Credentials != null) |
| | 13363 | | { |
| 4 | 13364 | | cancellationToken.ThrowIfCancellationRequested(); |
| 4 | 13365 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 13366 | | } |
| | 13367 | | // Send Request |
| 4 | 13368 | | if (_shouldTrace) |
| | 13369 | | { |
| 0 | 13370 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 13371 | | } |
| 4 | 13372 | | cancellationToken.ThrowIfCancellationRequested(); |
| 4 | 13373 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 4 | 13374 | | if (_shouldTrace) |
| | 13375 | | { |
| 0 | 13376 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 13377 | | } |
| 4 | 13378 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 4 | 13379 | | cancellationToken.ThrowIfCancellationRequested(); |
| 4 | 13380 | | string _responseContent = null; |
| 4 | 13381 | | if ((int)_statusCode != 201) |
| | 13382 | | { |
| 0 | 13383 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 13384 | | try |
| | 13385 | | { |
| 0 | 13386 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 13387 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 13388 | | if (_errorBody != null) |
| | 13389 | | { |
| 0 | 13390 | | ex.Body = _errorBody; |
| | 13391 | | } |
| 0 | 13392 | | } |
| 0 | 13393 | | catch (JsonException) |
| | 13394 | | { |
| | 13395 | | // Ignore the exception |
| 0 | 13396 | | } |
| 0 | 13397 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 13398 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 13399 | | if (_shouldTrace) |
| | 13400 | | { |
| 0 | 13401 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 13402 | | } |
| 0 | 13403 | | _httpRequest.Dispose(); |
| 0 | 13404 | | if (_httpResponse != null) |
| | 13405 | | { |
| 0 | 13406 | | _httpResponse.Dispose(); |
| | 13407 | | } |
| 0 | 13408 | | throw ex; |
| | 13409 | | } |
| | 13410 | | // Create Result |
| 4 | 13411 | | var _result = new HttpOperationResponse<int?>(); |
| 4 | 13412 | | _result.Request = _httpRequest; |
| 4 | 13413 | | _result.Response = _httpResponse; |
| | 13414 | | // Deserialize Response |
| 4 | 13415 | | if ((int)_statusCode == 201) |
| | 13416 | | { |
| 4 | 13417 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 13418 | | try |
| | 13419 | | { |
| 4 | 13420 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<int?>(_responseContent, Client.D |
| 4 | 13421 | | } |
| 0 | 13422 | | catch (JsonException ex) |
| | 13423 | | { |
| 0 | 13424 | | _httpRequest.Dispose(); |
| 0 | 13425 | | if (_httpResponse != null) |
| | 13426 | | { |
| 0 | 13427 | | _httpResponse.Dispose(); |
| | 13428 | | } |
| 0 | 13429 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 13430 | | } |
| | 13431 | | } |
| 4 | 13432 | | if (_shouldTrace) |
| | 13433 | | { |
| 0 | 13434 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 13435 | | } |
| 4 | 13436 | | return _result; |
| 4 | 13437 | | } |
| | 13438 | |
|
| | 13439 | | /// <summary> |
| | 13440 | | /// Gets information about a regular expression entity in a version of the |
| | 13441 | | /// application. |
| | 13442 | | /// </summary> |
| | 13443 | | /// <param name='appId'> |
| | 13444 | | /// The application ID. |
| | 13445 | | /// </param> |
| | 13446 | | /// <param name='versionId'> |
| | 13447 | | /// The version ID. |
| | 13448 | | /// </param> |
| | 13449 | | /// <param name='regexEntityId'> |
| | 13450 | | /// The regular expression entity model ID. |
| | 13451 | | /// </param> |
| | 13452 | | /// <param name='customHeaders'> |
| | 13453 | | /// Headers that will be added to request. |
| | 13454 | | /// </param> |
| | 13455 | | /// <param name='cancellationToken'> |
| | 13456 | | /// The cancellation token. |
| | 13457 | | /// </param> |
| | 13458 | | /// <exception cref="ErrorResponseException"> |
| | 13459 | | /// Thrown when the operation returned an invalid status code |
| | 13460 | | /// </exception> |
| | 13461 | | /// <exception cref="SerializationException"> |
| | 13462 | | /// Thrown when unable to deserialize the response |
| | 13463 | | /// </exception> |
| | 13464 | | /// <exception cref="ValidationException"> |
| | 13465 | | /// Thrown when a required parameter is null |
| | 13466 | | /// </exception> |
| | 13467 | | /// <exception cref="System.ArgumentNullException"> |
| | 13468 | | /// Thrown when a required parameter is null |
| | 13469 | | /// </exception> |
| | 13470 | | /// <return> |
| | 13471 | | /// A response object containing the response body and response headers. |
| | 13472 | | /// </return> |
| | 13473 | | public async Task<HttpOperationResponse<RegexEntityExtractor>> GetRegexEntityEntityInfoWithHttpMessagesAsync(Sys |
| | 13474 | | { |
| 2 | 13475 | | if (Client.Endpoint == null) |
| | 13476 | | { |
| 0 | 13477 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 13478 | | } |
| 2 | 13479 | | if (versionId == null) |
| | 13480 | | { |
| 0 | 13481 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 13482 | | } |
| | 13483 | | // Tracing |
| 2 | 13484 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 13485 | | string _invocationId = null; |
| 2 | 13486 | | if (_shouldTrace) |
| | 13487 | | { |
| 0 | 13488 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 13489 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 13490 | | tracingParameters.Add("appId", appId); |
| 0 | 13491 | | tracingParameters.Add("versionId", versionId); |
| 0 | 13492 | | tracingParameters.Add("regexEntityId", regexEntityId); |
| 0 | 13493 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 13494 | | ServiceClientTracing.Enter(_invocationId, this, "GetRegexEntityEntityInfo", tracingParameters); |
| | 13495 | | } |
| | 13496 | | // Construct URL |
| 2 | 13497 | | var _baseUrl = Client.BaseUri; |
| 2 | 13498 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities |
| 2 | 13499 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 13500 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 13501 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 2 | 13502 | | _url = _url.Replace("{regexEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serial |
| | 13503 | | // Create HTTP transport objects |
| 2 | 13504 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 13505 | | HttpResponseMessage _httpResponse = null; |
| 2 | 13506 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 13507 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 13508 | | // Set Headers |
| | 13509 | |
|
| | 13510 | |
|
| 2 | 13511 | | if (customHeaders != null) |
| | 13512 | | { |
| 0 | 13513 | | foreach(var _header in customHeaders) |
| | 13514 | | { |
| 0 | 13515 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 13516 | | { |
| 0 | 13517 | | _httpRequest.Headers.Remove(_header.Key); |
| | 13518 | | } |
| 0 | 13519 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 13520 | | } |
| | 13521 | | } |
| | 13522 | |
|
| | 13523 | | // Serialize Request |
| 2 | 13524 | | string _requestContent = null; |
| | 13525 | | // Set Credentials |
| 2 | 13526 | | if (Client.Credentials != null) |
| | 13527 | | { |
| 2 | 13528 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 13529 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 13530 | | } |
| | 13531 | | // Send Request |
| 2 | 13532 | | if (_shouldTrace) |
| | 13533 | | { |
| 0 | 13534 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 13535 | | } |
| 2 | 13536 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 13537 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 13538 | | if (_shouldTrace) |
| | 13539 | | { |
| 0 | 13540 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 13541 | | } |
| 2 | 13542 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 13543 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 13544 | | string _responseContent = null; |
| 2 | 13545 | | if ((int)_statusCode != 200) |
| | 13546 | | { |
| 0 | 13547 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 13548 | | try |
| | 13549 | | { |
| 0 | 13550 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 13551 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 13552 | | if (_errorBody != null) |
| | 13553 | | { |
| 0 | 13554 | | ex.Body = _errorBody; |
| | 13555 | | } |
| 0 | 13556 | | } |
| 0 | 13557 | | catch (JsonException) |
| | 13558 | | { |
| | 13559 | | // Ignore the exception |
| 0 | 13560 | | } |
| 0 | 13561 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 13562 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 13563 | | if (_shouldTrace) |
| | 13564 | | { |
| 0 | 13565 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 13566 | | } |
| 0 | 13567 | | _httpRequest.Dispose(); |
| 0 | 13568 | | if (_httpResponse != null) |
| | 13569 | | { |
| 0 | 13570 | | _httpResponse.Dispose(); |
| | 13571 | | } |
| 0 | 13572 | | throw ex; |
| | 13573 | | } |
| | 13574 | | // Create Result |
| 2 | 13575 | | var _result = new HttpOperationResponse<RegexEntityExtractor>(); |
| 2 | 13576 | | _result.Request = _httpRequest; |
| 2 | 13577 | | _result.Response = _httpResponse; |
| | 13578 | | // Deserialize Response |
| 2 | 13579 | | if ((int)_statusCode == 200) |
| | 13580 | | { |
| 2 | 13581 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 13582 | | try |
| | 13583 | | { |
| 2 | 13584 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<RegexEntityExtractor>(_responseC |
| 2 | 13585 | | } |
| 0 | 13586 | | catch (JsonException ex) |
| | 13587 | | { |
| 0 | 13588 | | _httpRequest.Dispose(); |
| 0 | 13589 | | if (_httpResponse != null) |
| | 13590 | | { |
| 0 | 13591 | | _httpResponse.Dispose(); |
| | 13592 | | } |
| 0 | 13593 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 13594 | | } |
| | 13595 | | } |
| 2 | 13596 | | if (_shouldTrace) |
| | 13597 | | { |
| 0 | 13598 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 13599 | | } |
| 2 | 13600 | | return _result; |
| 2 | 13601 | | } |
| | 13602 | |
|
| | 13603 | | /// <summary> |
| | 13604 | | /// Updates the regular expression entity in a version of the application. |
| | 13605 | | /// </summary> |
| | 13606 | | /// <param name='appId'> |
| | 13607 | | /// The application ID. |
| | 13608 | | /// </param> |
| | 13609 | | /// <param name='versionId'> |
| | 13610 | | /// The version ID. |
| | 13611 | | /// </param> |
| | 13612 | | /// <param name='regexEntityId'> |
| | 13613 | | /// The regular expression entity extractor ID. |
| | 13614 | | /// </param> |
| | 13615 | | /// <param name='regexEntityUpdateObject'> |
| | 13616 | | /// An object containing the new entity name and regex pattern. |
| | 13617 | | /// </param> |
| | 13618 | | /// <param name='customHeaders'> |
| | 13619 | | /// Headers that will be added to request. |
| | 13620 | | /// </param> |
| | 13621 | | /// <param name='cancellationToken'> |
| | 13622 | | /// The cancellation token. |
| | 13623 | | /// </param> |
| | 13624 | | /// <exception cref="ErrorResponseException"> |
| | 13625 | | /// Thrown when the operation returned an invalid status code |
| | 13626 | | /// </exception> |
| | 13627 | | /// <exception cref="SerializationException"> |
| | 13628 | | /// Thrown when unable to deserialize the response |
| | 13629 | | /// </exception> |
| | 13630 | | /// <exception cref="ValidationException"> |
| | 13631 | | /// Thrown when a required parameter is null |
| | 13632 | | /// </exception> |
| | 13633 | | /// <exception cref="System.ArgumentNullException"> |
| | 13634 | | /// Thrown when a required parameter is null |
| | 13635 | | /// </exception> |
| | 13636 | | /// <return> |
| | 13637 | | /// A response object containing the response body and response headers. |
| | 13638 | | /// </return> |
| | 13639 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateRegexEntityModelWithHttpMessagesAsync(System.Gui |
| | 13640 | | { |
| 1 | 13641 | | if (Client.Endpoint == null) |
| | 13642 | | { |
| 0 | 13643 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 13644 | | } |
| 1 | 13645 | | if (versionId == null) |
| | 13646 | | { |
| 0 | 13647 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 13648 | | } |
| 1 | 13649 | | if (regexEntityUpdateObject == null) |
| | 13650 | | { |
| 0 | 13651 | | throw new ValidationException(ValidationRules.CannotBeNull, "regexEntityUpdateObject"); |
| | 13652 | | } |
| | 13653 | | // Tracing |
| 1 | 13654 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 13655 | | string _invocationId = null; |
| 1 | 13656 | | if (_shouldTrace) |
| | 13657 | | { |
| 0 | 13658 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 13659 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 13660 | | tracingParameters.Add("appId", appId); |
| 0 | 13661 | | tracingParameters.Add("versionId", versionId); |
| 0 | 13662 | | tracingParameters.Add("regexEntityId", regexEntityId); |
| 0 | 13663 | | tracingParameters.Add("regexEntityUpdateObject", regexEntityUpdateObject); |
| 0 | 13664 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 13665 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateRegexEntityModel", tracingParameters); |
| | 13666 | | } |
| | 13667 | | // Construct URL |
| 1 | 13668 | | var _baseUrl = Client.BaseUri; |
| 1 | 13669 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities |
| 1 | 13670 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 13671 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 13672 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 13673 | | _url = _url.Replace("{regexEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serial |
| | 13674 | | // Create HTTP transport objects |
| 1 | 13675 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 13676 | | HttpResponseMessage _httpResponse = null; |
| 1 | 13677 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 1 | 13678 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 13679 | | // Set Headers |
| | 13680 | |
|
| | 13681 | |
|
| 1 | 13682 | | if (customHeaders != null) |
| | 13683 | | { |
| 0 | 13684 | | foreach(var _header in customHeaders) |
| | 13685 | | { |
| 0 | 13686 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 13687 | | { |
| 0 | 13688 | | _httpRequest.Headers.Remove(_header.Key); |
| | 13689 | | } |
| 0 | 13690 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 13691 | | } |
| | 13692 | | } |
| | 13693 | |
|
| | 13694 | | // Serialize Request |
| 1 | 13695 | | string _requestContent = null; |
| 1 | 13696 | | if(regexEntityUpdateObject != null) |
| | 13697 | | { |
| 1 | 13698 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(regexEntityUpdateObject, Client.Ser |
| 1 | 13699 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 13700 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 13701 | | } |
| | 13702 | | // Set Credentials |
| 1 | 13703 | | if (Client.Credentials != null) |
| | 13704 | | { |
| 1 | 13705 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 13706 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 13707 | | } |
| | 13708 | | // Send Request |
| 1 | 13709 | | if (_shouldTrace) |
| | 13710 | | { |
| 0 | 13711 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 13712 | | } |
| 1 | 13713 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 13714 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 13715 | | if (_shouldTrace) |
| | 13716 | | { |
| 0 | 13717 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 13718 | | } |
| 1 | 13719 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 13720 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 13721 | | string _responseContent = null; |
| 1 | 13722 | | if ((int)_statusCode != 200) |
| | 13723 | | { |
| 0 | 13724 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 13725 | | try |
| | 13726 | | { |
| 0 | 13727 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 13728 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 13729 | | if (_errorBody != null) |
| | 13730 | | { |
| 0 | 13731 | | ex.Body = _errorBody; |
| | 13732 | | } |
| 0 | 13733 | | } |
| 0 | 13734 | | catch (JsonException) |
| | 13735 | | { |
| | 13736 | | // Ignore the exception |
| 0 | 13737 | | } |
| 0 | 13738 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 13739 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 13740 | | if (_shouldTrace) |
| | 13741 | | { |
| 0 | 13742 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 13743 | | } |
| 0 | 13744 | | _httpRequest.Dispose(); |
| 0 | 13745 | | if (_httpResponse != null) |
| | 13746 | | { |
| 0 | 13747 | | _httpResponse.Dispose(); |
| | 13748 | | } |
| 0 | 13749 | | throw ex; |
| | 13750 | | } |
| | 13751 | | // Create Result |
| 1 | 13752 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 13753 | | _result.Request = _httpRequest; |
| 1 | 13754 | | _result.Response = _httpResponse; |
| | 13755 | | // Deserialize Response |
| 1 | 13756 | | if ((int)_statusCode == 200) |
| | 13757 | | { |
| 1 | 13758 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 13759 | | try |
| | 13760 | | { |
| 1 | 13761 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 13762 | | } |
| 0 | 13763 | | catch (JsonException ex) |
| | 13764 | | { |
| 0 | 13765 | | _httpRequest.Dispose(); |
| 0 | 13766 | | if (_httpResponse != null) |
| | 13767 | | { |
| 0 | 13768 | | _httpResponse.Dispose(); |
| | 13769 | | } |
| 0 | 13770 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 13771 | | } |
| | 13772 | | } |
| 1 | 13773 | | if (_shouldTrace) |
| | 13774 | | { |
| 0 | 13775 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 13776 | | } |
| 1 | 13777 | | return _result; |
| 1 | 13778 | | } |
| | 13779 | |
|
| | 13780 | | /// <summary> |
| | 13781 | | /// Deletes a regular expression entity from a version of the application. |
| | 13782 | | /// </summary> |
| | 13783 | | /// <param name='appId'> |
| | 13784 | | /// The application ID. |
| | 13785 | | /// </param> |
| | 13786 | | /// <param name='versionId'> |
| | 13787 | | /// The version ID. |
| | 13788 | | /// </param> |
| | 13789 | | /// <param name='regexEntityId'> |
| | 13790 | | /// The regular expression entity extractor ID. |
| | 13791 | | /// </param> |
| | 13792 | | /// <param name='customHeaders'> |
| | 13793 | | /// Headers that will be added to request. |
| | 13794 | | /// </param> |
| | 13795 | | /// <param name='cancellationToken'> |
| | 13796 | | /// The cancellation token. |
| | 13797 | | /// </param> |
| | 13798 | | /// <exception cref="ErrorResponseException"> |
| | 13799 | | /// Thrown when the operation returned an invalid status code |
| | 13800 | | /// </exception> |
| | 13801 | | /// <exception cref="SerializationException"> |
| | 13802 | | /// Thrown when unable to deserialize the response |
| | 13803 | | /// </exception> |
| | 13804 | | /// <exception cref="ValidationException"> |
| | 13805 | | /// Thrown when a required parameter is null |
| | 13806 | | /// </exception> |
| | 13807 | | /// <exception cref="System.ArgumentNullException"> |
| | 13808 | | /// Thrown when a required parameter is null |
| | 13809 | | /// </exception> |
| | 13810 | | /// <return> |
| | 13811 | | /// A response object containing the response body and response headers. |
| | 13812 | | /// </return> |
| | 13813 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteRegexEntityModelWithHttpMessagesAsync(System.Gui |
| | 13814 | | { |
| 10 | 13815 | | if (Client.Endpoint == null) |
| | 13816 | | { |
| 0 | 13817 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 13818 | | } |
| 10 | 13819 | | if (versionId == null) |
| | 13820 | | { |
| 0 | 13821 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 13822 | | } |
| | 13823 | | // Tracing |
| 10 | 13824 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 10 | 13825 | | string _invocationId = null; |
| 10 | 13826 | | if (_shouldTrace) |
| | 13827 | | { |
| 0 | 13828 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 13829 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 13830 | | tracingParameters.Add("appId", appId); |
| 0 | 13831 | | tracingParameters.Add("versionId", versionId); |
| 0 | 13832 | | tracingParameters.Add("regexEntityId", regexEntityId); |
| 0 | 13833 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 13834 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteRegexEntityModel", tracingParameters); |
| | 13835 | | } |
| | 13836 | | // Construct URL |
| 10 | 13837 | | var _baseUrl = Client.BaseUri; |
| 10 | 13838 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities |
| 10 | 13839 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 10 | 13840 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 10 | 13841 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 10 | 13842 | | _url = _url.Replace("{regexEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.Serial |
| | 13843 | | // Create HTTP transport objects |
| 10 | 13844 | | var _httpRequest = new HttpRequestMessage(); |
| 10 | 13845 | | HttpResponseMessage _httpResponse = null; |
| 10 | 13846 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 10 | 13847 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 13848 | | // Set Headers |
| | 13849 | |
|
| | 13850 | |
|
| 10 | 13851 | | if (customHeaders != null) |
| | 13852 | | { |
| 0 | 13853 | | foreach(var _header in customHeaders) |
| | 13854 | | { |
| 0 | 13855 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 13856 | | { |
| 0 | 13857 | | _httpRequest.Headers.Remove(_header.Key); |
| | 13858 | | } |
| 0 | 13859 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 13860 | | } |
| | 13861 | | } |
| | 13862 | |
|
| | 13863 | | // Serialize Request |
| 10 | 13864 | | string _requestContent = null; |
| | 13865 | | // Set Credentials |
| 10 | 13866 | | if (Client.Credentials != null) |
| | 13867 | | { |
| 10 | 13868 | | cancellationToken.ThrowIfCancellationRequested(); |
| 10 | 13869 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 13870 | | } |
| | 13871 | | // Send Request |
| 10 | 13872 | | if (_shouldTrace) |
| | 13873 | | { |
| 0 | 13874 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 13875 | | } |
| 10 | 13876 | | cancellationToken.ThrowIfCancellationRequested(); |
| 10 | 13877 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 10 | 13878 | | if (_shouldTrace) |
| | 13879 | | { |
| 0 | 13880 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 13881 | | } |
| 10 | 13882 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 10 | 13883 | | cancellationToken.ThrowIfCancellationRequested(); |
| 10 | 13884 | | string _responseContent = null; |
| 10 | 13885 | | if ((int)_statusCode != 200) |
| | 13886 | | { |
| 0 | 13887 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 13888 | | try |
| | 13889 | | { |
| 0 | 13890 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 13891 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 13892 | | if (_errorBody != null) |
| | 13893 | | { |
| 0 | 13894 | | ex.Body = _errorBody; |
| | 13895 | | } |
| 0 | 13896 | | } |
| 0 | 13897 | | catch (JsonException) |
| | 13898 | | { |
| | 13899 | | // Ignore the exception |
| 0 | 13900 | | } |
| 0 | 13901 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 13902 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 13903 | | if (_shouldTrace) |
| | 13904 | | { |
| 0 | 13905 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 13906 | | } |
| 0 | 13907 | | _httpRequest.Dispose(); |
| 0 | 13908 | | if (_httpResponse != null) |
| | 13909 | | { |
| 0 | 13910 | | _httpResponse.Dispose(); |
| | 13911 | | } |
| 0 | 13912 | | throw ex; |
| | 13913 | | } |
| | 13914 | | // Create Result |
| 10 | 13915 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 10 | 13916 | | _result.Request = _httpRequest; |
| 10 | 13917 | | _result.Response = _httpResponse; |
| | 13918 | | // Deserialize Response |
| 10 | 13919 | | if ((int)_statusCode == 200) |
| | 13920 | | { |
| 10 | 13921 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 13922 | | try |
| | 13923 | | { |
| 10 | 13924 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 10 | 13925 | | } |
| 0 | 13926 | | catch (JsonException ex) |
| | 13927 | | { |
| 0 | 13928 | | _httpRequest.Dispose(); |
| 0 | 13929 | | if (_httpResponse != null) |
| | 13930 | | { |
| 0 | 13931 | | _httpResponse.Dispose(); |
| | 13932 | | } |
| 0 | 13933 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 13934 | | } |
| | 13935 | | } |
| 10 | 13936 | | if (_shouldTrace) |
| | 13937 | | { |
| 0 | 13938 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 13939 | | } |
| 10 | 13940 | | return _result; |
| 10 | 13941 | | } |
| | 13942 | |
|
| | 13943 | | /// <summary> |
| | 13944 | | /// Gets information about the Pattern.Any model in a version of the |
| | 13945 | | /// application. |
| | 13946 | | /// </summary> |
| | 13947 | | /// <param name='appId'> |
| | 13948 | | /// The application ID. |
| | 13949 | | /// </param> |
| | 13950 | | /// <param name='versionId'> |
| | 13951 | | /// The version ID. |
| | 13952 | | /// </param> |
| | 13953 | | /// <param name='entityId'> |
| | 13954 | | /// The entity extractor ID. |
| | 13955 | | /// </param> |
| | 13956 | | /// <param name='customHeaders'> |
| | 13957 | | /// Headers that will be added to request. |
| | 13958 | | /// </param> |
| | 13959 | | /// <param name='cancellationToken'> |
| | 13960 | | /// The cancellation token. |
| | 13961 | | /// </param> |
| | 13962 | | /// <exception cref="ErrorResponseException"> |
| | 13963 | | /// Thrown when the operation returned an invalid status code |
| | 13964 | | /// </exception> |
| | 13965 | | /// <exception cref="SerializationException"> |
| | 13966 | | /// Thrown when unable to deserialize the response |
| | 13967 | | /// </exception> |
| | 13968 | | /// <exception cref="ValidationException"> |
| | 13969 | | /// Thrown when a required parameter is null |
| | 13970 | | /// </exception> |
| | 13971 | | /// <exception cref="System.ArgumentNullException"> |
| | 13972 | | /// Thrown when a required parameter is null |
| | 13973 | | /// </exception> |
| | 13974 | | /// <return> |
| | 13975 | | /// A response object containing the response body and response headers. |
| | 13976 | | /// </return> |
| | 13977 | | public async Task<HttpOperationResponse<PatternAnyEntityExtractor>> GetPatternAnyEntityInfoWithHttpMessagesAsync |
| | 13978 | | { |
| 3 | 13979 | | if (Client.Endpoint == null) |
| | 13980 | | { |
| 0 | 13981 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 13982 | | } |
| 3 | 13983 | | if (versionId == null) |
| | 13984 | | { |
| 0 | 13985 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 13986 | | } |
| | 13987 | | // Tracing |
| 3 | 13988 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 3 | 13989 | | string _invocationId = null; |
| 3 | 13990 | | if (_shouldTrace) |
| | 13991 | | { |
| 0 | 13992 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 13993 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 13994 | | tracingParameters.Add("appId", appId); |
| 0 | 13995 | | tracingParameters.Add("versionId", versionId); |
| 0 | 13996 | | tracingParameters.Add("entityId", entityId); |
| 0 | 13997 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 13998 | | ServiceClientTracing.Enter(_invocationId, this, "GetPatternAnyEntityInfo", tracingParameters); |
| | 13999 | | } |
| | 14000 | | // Construct URL |
| 3 | 14001 | | var _baseUrl = Client.BaseUri; |
| 3 | 14002 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 3 | 14003 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 3 | 14004 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 3 | 14005 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 3 | 14006 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 14007 | | // Create HTTP transport objects |
| 3 | 14008 | | var _httpRequest = new HttpRequestMessage(); |
| 3 | 14009 | | HttpResponseMessage _httpResponse = null; |
| 3 | 14010 | | _httpRequest.Method = new HttpMethod("GET"); |
| 3 | 14011 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 14012 | | // Set Headers |
| | 14013 | |
|
| | 14014 | |
|
| 3 | 14015 | | if (customHeaders != null) |
| | 14016 | | { |
| 0 | 14017 | | foreach(var _header in customHeaders) |
| | 14018 | | { |
| 0 | 14019 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 14020 | | { |
| 0 | 14021 | | _httpRequest.Headers.Remove(_header.Key); |
| | 14022 | | } |
| 0 | 14023 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 14024 | | } |
| | 14025 | | } |
| | 14026 | |
|
| | 14027 | | // Serialize Request |
| 3 | 14028 | | string _requestContent = null; |
| | 14029 | | // Set Credentials |
| 3 | 14030 | | if (Client.Credentials != null) |
| | 14031 | | { |
| 3 | 14032 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 14033 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 14034 | | } |
| | 14035 | | // Send Request |
| 3 | 14036 | | if (_shouldTrace) |
| | 14037 | | { |
| 0 | 14038 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 14039 | | } |
| 3 | 14040 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 14041 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 3 | 14042 | | if (_shouldTrace) |
| | 14043 | | { |
| 0 | 14044 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 14045 | | } |
| 3 | 14046 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 3 | 14047 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 14048 | | string _responseContent = null; |
| 3 | 14049 | | if ((int)_statusCode != 200) |
| | 14050 | | { |
| 0 | 14051 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 14052 | | try |
| | 14053 | | { |
| 0 | 14054 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 14055 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 14056 | | if (_errorBody != null) |
| | 14057 | | { |
| 0 | 14058 | | ex.Body = _errorBody; |
| | 14059 | | } |
| 0 | 14060 | | } |
| 0 | 14061 | | catch (JsonException) |
| | 14062 | | { |
| | 14063 | | // Ignore the exception |
| 0 | 14064 | | } |
| 0 | 14065 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 14066 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 14067 | | if (_shouldTrace) |
| | 14068 | | { |
| 0 | 14069 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 14070 | | } |
| 0 | 14071 | | _httpRequest.Dispose(); |
| 0 | 14072 | | if (_httpResponse != null) |
| | 14073 | | { |
| 0 | 14074 | | _httpResponse.Dispose(); |
| | 14075 | | } |
| 0 | 14076 | | throw ex; |
| | 14077 | | } |
| | 14078 | | // Create Result |
| 3 | 14079 | | var _result = new HttpOperationResponse<PatternAnyEntityExtractor>(); |
| 3 | 14080 | | _result.Request = _httpRequest; |
| 3 | 14081 | | _result.Response = _httpResponse; |
| | 14082 | | // Deserialize Response |
| 3 | 14083 | | if ((int)_statusCode == 200) |
| | 14084 | | { |
| 3 | 14085 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 14086 | | try |
| | 14087 | | { |
| 3 | 14088 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<PatternAnyEntityExtractor>(_resp |
| 3 | 14089 | | } |
| 0 | 14090 | | catch (JsonException ex) |
| | 14091 | | { |
| 0 | 14092 | | _httpRequest.Dispose(); |
| 0 | 14093 | | if (_httpResponse != null) |
| | 14094 | | { |
| 0 | 14095 | | _httpResponse.Dispose(); |
| | 14096 | | } |
| 0 | 14097 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 14098 | | } |
| | 14099 | | } |
| 3 | 14100 | | if (_shouldTrace) |
| | 14101 | | { |
| 0 | 14102 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 14103 | | } |
| 3 | 14104 | | return _result; |
| 3 | 14105 | | } |
| | 14106 | |
|
| | 14107 | | /// <summary> |
| | 14108 | | /// Updates the name and explicit (exception) list of a Pattern.Any entity |
| | 14109 | | /// model in a version of the application. |
| | 14110 | | /// </summary> |
| | 14111 | | /// <param name='appId'> |
| | 14112 | | /// The application ID. |
| | 14113 | | /// </param> |
| | 14114 | | /// <param name='versionId'> |
| | 14115 | | /// The version ID. |
| | 14116 | | /// </param> |
| | 14117 | | /// <param name='entityId'> |
| | 14118 | | /// The Pattern.Any entity extractor ID. |
| | 14119 | | /// </param> |
| | 14120 | | /// <param name='patternAnyUpdateObject'> |
| | 14121 | | /// An object containing the explicit list of the Pattern.Any entity. |
| | 14122 | | /// </param> |
| | 14123 | | /// <param name='customHeaders'> |
| | 14124 | | /// Headers that will be added to request. |
| | 14125 | | /// </param> |
| | 14126 | | /// <param name='cancellationToken'> |
| | 14127 | | /// The cancellation token. |
| | 14128 | | /// </param> |
| | 14129 | | /// <exception cref="ErrorResponseException"> |
| | 14130 | | /// Thrown when the operation returned an invalid status code |
| | 14131 | | /// </exception> |
| | 14132 | | /// <exception cref="SerializationException"> |
| | 14133 | | /// Thrown when unable to deserialize the response |
| | 14134 | | /// </exception> |
| | 14135 | | /// <exception cref="ValidationException"> |
| | 14136 | | /// Thrown when a required parameter is null |
| | 14137 | | /// </exception> |
| | 14138 | | /// <exception cref="System.ArgumentNullException"> |
| | 14139 | | /// Thrown when a required parameter is null |
| | 14140 | | /// </exception> |
| | 14141 | | /// <return> |
| | 14142 | | /// A response object containing the response body and response headers. |
| | 14143 | | /// </return> |
| | 14144 | | public async Task<HttpOperationResponse<OperationStatus>> UpdatePatternAnyEntityModelWithHttpMessagesAsync(Syste |
| | 14145 | | { |
| 1 | 14146 | | if (Client.Endpoint == null) |
| | 14147 | | { |
| 0 | 14148 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 14149 | | } |
| 1 | 14150 | | if (versionId == null) |
| | 14151 | | { |
| 0 | 14152 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 14153 | | } |
| 1 | 14154 | | if (patternAnyUpdateObject == null) |
| | 14155 | | { |
| 0 | 14156 | | throw new ValidationException(ValidationRules.CannotBeNull, "patternAnyUpdateObject"); |
| | 14157 | | } |
| | 14158 | | // Tracing |
| 1 | 14159 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 14160 | | string _invocationId = null; |
| 1 | 14161 | | if (_shouldTrace) |
| | 14162 | | { |
| 0 | 14163 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 14164 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 14165 | | tracingParameters.Add("appId", appId); |
| 0 | 14166 | | tracingParameters.Add("versionId", versionId); |
| 0 | 14167 | | tracingParameters.Add("entityId", entityId); |
| 0 | 14168 | | tracingParameters.Add("patternAnyUpdateObject", patternAnyUpdateObject); |
| 0 | 14169 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 14170 | | ServiceClientTracing.Enter(_invocationId, this, "UpdatePatternAnyEntityModel", tracingParameters); |
| | 14171 | | } |
| | 14172 | | // Construct URL |
| 1 | 14173 | | var _baseUrl = Client.BaseUri; |
| 1 | 14174 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 1 | 14175 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 14176 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 14177 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 14178 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 14179 | | // Create HTTP transport objects |
| 1 | 14180 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 14181 | | HttpResponseMessage _httpResponse = null; |
| 1 | 14182 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 1 | 14183 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 14184 | | // Set Headers |
| | 14185 | |
|
| | 14186 | |
|
| 1 | 14187 | | if (customHeaders != null) |
| | 14188 | | { |
| 0 | 14189 | | foreach(var _header in customHeaders) |
| | 14190 | | { |
| 0 | 14191 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 14192 | | { |
| 0 | 14193 | | _httpRequest.Headers.Remove(_header.Key); |
| | 14194 | | } |
| 0 | 14195 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 14196 | | } |
| | 14197 | | } |
| | 14198 | |
|
| | 14199 | | // Serialize Request |
| 1 | 14200 | | string _requestContent = null; |
| 1 | 14201 | | if(patternAnyUpdateObject != null) |
| | 14202 | | { |
| 1 | 14203 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(patternAnyUpdateObject, Client.Seri |
| 1 | 14204 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 14205 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 14206 | | } |
| | 14207 | | // Set Credentials |
| 1 | 14208 | | if (Client.Credentials != null) |
| | 14209 | | { |
| 1 | 14210 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 14211 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 14212 | | } |
| | 14213 | | // Send Request |
| 1 | 14214 | | if (_shouldTrace) |
| | 14215 | | { |
| 0 | 14216 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 14217 | | } |
| 1 | 14218 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 14219 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 14220 | | if (_shouldTrace) |
| | 14221 | | { |
| 0 | 14222 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 14223 | | } |
| 1 | 14224 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 14225 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 14226 | | string _responseContent = null; |
| 1 | 14227 | | if ((int)_statusCode != 200) |
| | 14228 | | { |
| 0 | 14229 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 14230 | | try |
| | 14231 | | { |
| 0 | 14232 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 14233 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 14234 | | if (_errorBody != null) |
| | 14235 | | { |
| 0 | 14236 | | ex.Body = _errorBody; |
| | 14237 | | } |
| 0 | 14238 | | } |
| 0 | 14239 | | catch (JsonException) |
| | 14240 | | { |
| | 14241 | | // Ignore the exception |
| 0 | 14242 | | } |
| 0 | 14243 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 14244 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 14245 | | if (_shouldTrace) |
| | 14246 | | { |
| 0 | 14247 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 14248 | | } |
| 0 | 14249 | | _httpRequest.Dispose(); |
| 0 | 14250 | | if (_httpResponse != null) |
| | 14251 | | { |
| 0 | 14252 | | _httpResponse.Dispose(); |
| | 14253 | | } |
| 0 | 14254 | | throw ex; |
| | 14255 | | } |
| | 14256 | | // Create Result |
| 1 | 14257 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 14258 | | _result.Request = _httpRequest; |
| 1 | 14259 | | _result.Response = _httpResponse; |
| | 14260 | | // Deserialize Response |
| 1 | 14261 | | if ((int)_statusCode == 200) |
| | 14262 | | { |
| 1 | 14263 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 14264 | | try |
| | 14265 | | { |
| 1 | 14266 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 14267 | | } |
| 0 | 14268 | | catch (JsonException ex) |
| | 14269 | | { |
| 0 | 14270 | | _httpRequest.Dispose(); |
| 0 | 14271 | | if (_httpResponse != null) |
| | 14272 | | { |
| 0 | 14273 | | _httpResponse.Dispose(); |
| | 14274 | | } |
| 0 | 14275 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 14276 | | } |
| | 14277 | | } |
| 1 | 14278 | | if (_shouldTrace) |
| | 14279 | | { |
| 0 | 14280 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 14281 | | } |
| 1 | 14282 | | return _result; |
| 1 | 14283 | | } |
| | 14284 | |
|
| | 14285 | | /// <summary> |
| | 14286 | | /// Deletes a Pattern.Any entity extractor from a version of the application. |
| | 14287 | | /// </summary> |
| | 14288 | | /// <param name='appId'> |
| | 14289 | | /// The application ID. |
| | 14290 | | /// </param> |
| | 14291 | | /// <param name='versionId'> |
| | 14292 | | /// The version ID. |
| | 14293 | | /// </param> |
| | 14294 | | /// <param name='entityId'> |
| | 14295 | | /// The Pattern.Any entity extractor ID. |
| | 14296 | | /// </param> |
| | 14297 | | /// <param name='customHeaders'> |
| | 14298 | | /// Headers that will be added to request. |
| | 14299 | | /// </param> |
| | 14300 | | /// <param name='cancellationToken'> |
| | 14301 | | /// The cancellation token. |
| | 14302 | | /// </param> |
| | 14303 | | /// <exception cref="ErrorResponseException"> |
| | 14304 | | /// Thrown when the operation returned an invalid status code |
| | 14305 | | /// </exception> |
| | 14306 | | /// <exception cref="SerializationException"> |
| | 14307 | | /// Thrown when unable to deserialize the response |
| | 14308 | | /// </exception> |
| | 14309 | | /// <exception cref="ValidationException"> |
| | 14310 | | /// Thrown when a required parameter is null |
| | 14311 | | /// </exception> |
| | 14312 | | /// <exception cref="System.ArgumentNullException"> |
| | 14313 | | /// Thrown when a required parameter is null |
| | 14314 | | /// </exception> |
| | 14315 | | /// <return> |
| | 14316 | | /// A response object containing the response body and response headers. |
| | 14317 | | /// </return> |
| | 14318 | | public async Task<HttpOperationResponse<OperationStatus>> DeletePatternAnyEntityModelWithHttpMessagesAsync(Syste |
| | 14319 | | { |
| 15 | 14320 | | if (Client.Endpoint == null) |
| | 14321 | | { |
| 0 | 14322 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 14323 | | } |
| 15 | 14324 | | if (versionId == null) |
| | 14325 | | { |
| 0 | 14326 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 14327 | | } |
| | 14328 | | // Tracing |
| 15 | 14329 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 15 | 14330 | | string _invocationId = null; |
| 15 | 14331 | | if (_shouldTrace) |
| | 14332 | | { |
| 0 | 14333 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 14334 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 14335 | | tracingParameters.Add("appId", appId); |
| 0 | 14336 | | tracingParameters.Add("versionId", versionId); |
| 0 | 14337 | | tracingParameters.Add("entityId", entityId); |
| 0 | 14338 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 14339 | | ServiceClientTracing.Enter(_invocationId, this, "DeletePatternAnyEntityModel", tracingParameters); |
| | 14340 | | } |
| | 14341 | | // Construct URL |
| 15 | 14342 | | var _baseUrl = Client.BaseUri; |
| 15 | 14343 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 15 | 14344 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 15 | 14345 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 15 | 14346 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 15 | 14347 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| | 14348 | | // Create HTTP transport objects |
| 15 | 14349 | | var _httpRequest = new HttpRequestMessage(); |
| 15 | 14350 | | HttpResponseMessage _httpResponse = null; |
| 15 | 14351 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 15 | 14352 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 14353 | | // Set Headers |
| | 14354 | |
|
| | 14355 | |
|
| 15 | 14356 | | if (customHeaders != null) |
| | 14357 | | { |
| 0 | 14358 | | foreach(var _header in customHeaders) |
| | 14359 | | { |
| 0 | 14360 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 14361 | | { |
| 0 | 14362 | | _httpRequest.Headers.Remove(_header.Key); |
| | 14363 | | } |
| 0 | 14364 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 14365 | | } |
| | 14366 | | } |
| | 14367 | |
|
| | 14368 | | // Serialize Request |
| 15 | 14369 | | string _requestContent = null; |
| | 14370 | | // Set Credentials |
| 15 | 14371 | | if (Client.Credentials != null) |
| | 14372 | | { |
| 15 | 14373 | | cancellationToken.ThrowIfCancellationRequested(); |
| 15 | 14374 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 14375 | | } |
| | 14376 | | // Send Request |
| 15 | 14377 | | if (_shouldTrace) |
| | 14378 | | { |
| 0 | 14379 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 14380 | | } |
| 15 | 14381 | | cancellationToken.ThrowIfCancellationRequested(); |
| 15 | 14382 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 15 | 14383 | | if (_shouldTrace) |
| | 14384 | | { |
| 0 | 14385 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 14386 | | } |
| 15 | 14387 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 15 | 14388 | | cancellationToken.ThrowIfCancellationRequested(); |
| 15 | 14389 | | string _responseContent = null; |
| 15 | 14390 | | if ((int)_statusCode != 200) |
| | 14391 | | { |
| 0 | 14392 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 14393 | | try |
| | 14394 | | { |
| 0 | 14395 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 14396 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 14397 | | if (_errorBody != null) |
| | 14398 | | { |
| 0 | 14399 | | ex.Body = _errorBody; |
| | 14400 | | } |
| 0 | 14401 | | } |
| 0 | 14402 | | catch (JsonException) |
| | 14403 | | { |
| | 14404 | | // Ignore the exception |
| 0 | 14405 | | } |
| 0 | 14406 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 14407 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 14408 | | if (_shouldTrace) |
| | 14409 | | { |
| 0 | 14410 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 14411 | | } |
| 0 | 14412 | | _httpRequest.Dispose(); |
| 0 | 14413 | | if (_httpResponse != null) |
| | 14414 | | { |
| 0 | 14415 | | _httpResponse.Dispose(); |
| | 14416 | | } |
| 0 | 14417 | | throw ex; |
| | 14418 | | } |
| | 14419 | | // Create Result |
| 15 | 14420 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 15 | 14421 | | _result.Request = _httpRequest; |
| 15 | 14422 | | _result.Response = _httpResponse; |
| | 14423 | | // Deserialize Response |
| 15 | 14424 | | if ((int)_statusCode == 200) |
| | 14425 | | { |
| 15 | 14426 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 14427 | | try |
| | 14428 | | { |
| 15 | 14429 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 15 | 14430 | | } |
| 0 | 14431 | | catch (JsonException ex) |
| | 14432 | | { |
| 0 | 14433 | | _httpRequest.Dispose(); |
| 0 | 14434 | | if (_httpResponse != null) |
| | 14435 | | { |
| 0 | 14436 | | _httpResponse.Dispose(); |
| | 14437 | | } |
| 0 | 14438 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 14439 | | } |
| | 14440 | | } |
| 15 | 14441 | | if (_shouldTrace) |
| | 14442 | | { |
| 0 | 14443 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 14444 | | } |
| 15 | 14445 | | return _result; |
| 15 | 14446 | | } |
| | 14447 | |
|
| | 14448 | | /// <summary> |
| | 14449 | | /// Get one role for a given entity in a version of the application |
| | 14450 | | /// </summary> |
| | 14451 | | /// <param name='appId'> |
| | 14452 | | /// The application ID. |
| | 14453 | | /// </param> |
| | 14454 | | /// <param name='versionId'> |
| | 14455 | | /// The version ID. |
| | 14456 | | /// </param> |
| | 14457 | | /// <param name='entityId'> |
| | 14458 | | /// entity ID. |
| | 14459 | | /// </param> |
| | 14460 | | /// <param name='roleId'> |
| | 14461 | | /// entity role ID. |
| | 14462 | | /// </param> |
| | 14463 | | /// <param name='customHeaders'> |
| | 14464 | | /// Headers that will be added to request. |
| | 14465 | | /// </param> |
| | 14466 | | /// <param name='cancellationToken'> |
| | 14467 | | /// The cancellation token. |
| | 14468 | | /// </param> |
| | 14469 | | /// <exception cref="ErrorResponseException"> |
| | 14470 | | /// Thrown when the operation returned an invalid status code |
| | 14471 | | /// </exception> |
| | 14472 | | /// <exception cref="SerializationException"> |
| | 14473 | | /// Thrown when unable to deserialize the response |
| | 14474 | | /// </exception> |
| | 14475 | | /// <exception cref="ValidationException"> |
| | 14476 | | /// Thrown when a required parameter is null |
| | 14477 | | /// </exception> |
| | 14478 | | /// <exception cref="System.ArgumentNullException"> |
| | 14479 | | /// Thrown when a required parameter is null |
| | 14480 | | /// </exception> |
| | 14481 | | /// <return> |
| | 14482 | | /// A response object containing the response body and response headers. |
| | 14483 | | /// </return> |
| | 14484 | | public async Task<HttpOperationResponse<EntityRole>> GetEntityRoleWithHttpMessagesAsync(System.Guid appId, strin |
| | 14485 | | { |
| 2 | 14486 | | if (Client.Endpoint == null) |
| | 14487 | | { |
| 0 | 14488 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 14489 | | } |
| 2 | 14490 | | if (versionId == null) |
| | 14491 | | { |
| 0 | 14492 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 14493 | | } |
| | 14494 | | // Tracing |
| 2 | 14495 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 14496 | | string _invocationId = null; |
| 2 | 14497 | | if (_shouldTrace) |
| | 14498 | | { |
| 0 | 14499 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 14500 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 14501 | | tracingParameters.Add("appId", appId); |
| 0 | 14502 | | tracingParameters.Add("versionId", versionId); |
| 0 | 14503 | | tracingParameters.Add("entityId", entityId); |
| 0 | 14504 | | tracingParameters.Add("roleId", roleId); |
| 0 | 14505 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 14506 | | ServiceClientTracing.Enter(_invocationId, this, "GetEntityRole", tracingParameters); |
| | 14507 | | } |
| | 14508 | | // Construct URL |
| 2 | 14509 | | var _baseUrl = Client.BaseUri; |
| 2 | 14510 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent |
| 2 | 14511 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 14512 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 14513 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 2 | 14514 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 2 | 14515 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 14516 | | // Create HTTP transport objects |
| 2 | 14517 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 14518 | | HttpResponseMessage _httpResponse = null; |
| 2 | 14519 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 14520 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 14521 | | // Set Headers |
| | 14522 | |
|
| | 14523 | |
|
| 2 | 14524 | | if (customHeaders != null) |
| | 14525 | | { |
| 0 | 14526 | | foreach(var _header in customHeaders) |
| | 14527 | | { |
| 0 | 14528 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 14529 | | { |
| 0 | 14530 | | _httpRequest.Headers.Remove(_header.Key); |
| | 14531 | | } |
| 0 | 14532 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 14533 | | } |
| | 14534 | | } |
| | 14535 | |
|
| | 14536 | | // Serialize Request |
| 2 | 14537 | | string _requestContent = null; |
| | 14538 | | // Set Credentials |
| 2 | 14539 | | if (Client.Credentials != null) |
| | 14540 | | { |
| 2 | 14541 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 14542 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 14543 | | } |
| | 14544 | | // Send Request |
| 2 | 14545 | | if (_shouldTrace) |
| | 14546 | | { |
| 0 | 14547 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 14548 | | } |
| 2 | 14549 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 14550 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 14551 | | if (_shouldTrace) |
| | 14552 | | { |
| 0 | 14553 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 14554 | | } |
| 2 | 14555 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 14556 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 14557 | | string _responseContent = null; |
| 2 | 14558 | | if ((int)_statusCode != 200) |
| | 14559 | | { |
| 0 | 14560 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 14561 | | try |
| | 14562 | | { |
| 0 | 14563 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 14564 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 14565 | | if (_errorBody != null) |
| | 14566 | | { |
| 0 | 14567 | | ex.Body = _errorBody; |
| | 14568 | | } |
| 0 | 14569 | | } |
| 0 | 14570 | | catch (JsonException) |
| | 14571 | | { |
| | 14572 | | // Ignore the exception |
| 0 | 14573 | | } |
| 0 | 14574 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 14575 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 14576 | | if (_shouldTrace) |
| | 14577 | | { |
| 0 | 14578 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 14579 | | } |
| 0 | 14580 | | _httpRequest.Dispose(); |
| 0 | 14581 | | if (_httpResponse != null) |
| | 14582 | | { |
| 0 | 14583 | | _httpResponse.Dispose(); |
| | 14584 | | } |
| 0 | 14585 | | throw ex; |
| | 14586 | | } |
| | 14587 | | // Create Result |
| 2 | 14588 | | var _result = new HttpOperationResponse<EntityRole>(); |
| 2 | 14589 | | _result.Request = _httpRequest; |
| 2 | 14590 | | _result.Response = _httpResponse; |
| | 14591 | | // Deserialize Response |
| 2 | 14592 | | if ((int)_statusCode == 200) |
| | 14593 | | { |
| 2 | 14594 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 14595 | | try |
| | 14596 | | { |
| 2 | 14597 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl |
| 2 | 14598 | | } |
| 0 | 14599 | | catch (JsonException ex) |
| | 14600 | | { |
| 0 | 14601 | | _httpRequest.Dispose(); |
| 0 | 14602 | | if (_httpResponse != null) |
| | 14603 | | { |
| 0 | 14604 | | _httpResponse.Dispose(); |
| | 14605 | | } |
| 0 | 14606 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 14607 | | } |
| | 14608 | | } |
| 2 | 14609 | | if (_shouldTrace) |
| | 14610 | | { |
| 0 | 14611 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 14612 | | } |
| 2 | 14613 | | return _result; |
| 2 | 14614 | | } |
| | 14615 | |
|
| | 14616 | | /// <summary> |
| | 14617 | | /// Update a role for a given entity in a version of the application. |
| | 14618 | | /// </summary> |
| | 14619 | | /// <param name='appId'> |
| | 14620 | | /// The application ID. |
| | 14621 | | /// </param> |
| | 14622 | | /// <param name='versionId'> |
| | 14623 | | /// The version ID. |
| | 14624 | | /// </param> |
| | 14625 | | /// <param name='entityId'> |
| | 14626 | | /// The entity ID. |
| | 14627 | | /// </param> |
| | 14628 | | /// <param name='roleId'> |
| | 14629 | | /// The entity role ID. |
| | 14630 | | /// </param> |
| | 14631 | | /// <param name='entityRoleUpdateObject'> |
| | 14632 | | /// The new entity role. |
| | 14633 | | /// </param> |
| | 14634 | | /// <param name='customHeaders'> |
| | 14635 | | /// Headers that will be added to request. |
| | 14636 | | /// </param> |
| | 14637 | | /// <param name='cancellationToken'> |
| | 14638 | | /// The cancellation token. |
| | 14639 | | /// </param> |
| | 14640 | | /// <exception cref="ErrorResponseException"> |
| | 14641 | | /// Thrown when the operation returned an invalid status code |
| | 14642 | | /// </exception> |
| | 14643 | | /// <exception cref="SerializationException"> |
| | 14644 | | /// Thrown when unable to deserialize the response |
| | 14645 | | /// </exception> |
| | 14646 | | /// <exception cref="ValidationException"> |
| | 14647 | | /// Thrown when a required parameter is null |
| | 14648 | | /// </exception> |
| | 14649 | | /// <exception cref="System.ArgumentNullException"> |
| | 14650 | | /// Thrown when a required parameter is null |
| | 14651 | | /// </exception> |
| | 14652 | | /// <return> |
| | 14653 | | /// A response object containing the response body and response headers. |
| | 14654 | | /// </return> |
| | 14655 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateEntityRoleWithHttpMessagesAsync(System.Guid appI |
| | 14656 | | { |
| 1 | 14657 | | if (Client.Endpoint == null) |
| | 14658 | | { |
| 0 | 14659 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 14660 | | } |
| 1 | 14661 | | if (versionId == null) |
| | 14662 | | { |
| 0 | 14663 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 14664 | | } |
| 1 | 14665 | | if (entityRoleUpdateObject == null) |
| | 14666 | | { |
| 0 | 14667 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject"); |
| | 14668 | | } |
| | 14669 | | // Tracing |
| 1 | 14670 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 14671 | | string _invocationId = null; |
| 1 | 14672 | | if (_shouldTrace) |
| | 14673 | | { |
| 0 | 14674 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 14675 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 14676 | | tracingParameters.Add("appId", appId); |
| 0 | 14677 | | tracingParameters.Add("versionId", versionId); |
| 0 | 14678 | | tracingParameters.Add("entityId", entityId); |
| 0 | 14679 | | tracingParameters.Add("roleId", roleId); |
| 0 | 14680 | | tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject); |
| 0 | 14681 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 14682 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateEntityRole", tracingParameters); |
| | 14683 | | } |
| | 14684 | | // Construct URL |
| 1 | 14685 | | var _baseUrl = Client.BaseUri; |
| 1 | 14686 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent |
| 1 | 14687 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 14688 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 14689 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 14690 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 14691 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 14692 | | // Create HTTP transport objects |
| 1 | 14693 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 14694 | | HttpResponseMessage _httpResponse = null; |
| 1 | 14695 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 1 | 14696 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 14697 | | // Set Headers |
| | 14698 | |
|
| | 14699 | |
|
| 1 | 14700 | | if (customHeaders != null) |
| | 14701 | | { |
| 0 | 14702 | | foreach(var _header in customHeaders) |
| | 14703 | | { |
| 0 | 14704 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 14705 | | { |
| 0 | 14706 | | _httpRequest.Headers.Remove(_header.Key); |
| | 14707 | | } |
| 0 | 14708 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 14709 | | } |
| | 14710 | | } |
| | 14711 | |
|
| | 14712 | | // Serialize Request |
| 1 | 14713 | | string _requestContent = null; |
| 1 | 14714 | | if(entityRoleUpdateObject != null) |
| | 14715 | | { |
| 1 | 14716 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri |
| 1 | 14717 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 14718 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 14719 | | } |
| | 14720 | | // Set Credentials |
| 1 | 14721 | | if (Client.Credentials != null) |
| | 14722 | | { |
| 1 | 14723 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 14724 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 14725 | | } |
| | 14726 | | // Send Request |
| 1 | 14727 | | if (_shouldTrace) |
| | 14728 | | { |
| 0 | 14729 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 14730 | | } |
| 1 | 14731 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 14732 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 14733 | | if (_shouldTrace) |
| | 14734 | | { |
| 0 | 14735 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 14736 | | } |
| 1 | 14737 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 14738 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 14739 | | string _responseContent = null; |
| 1 | 14740 | | if ((int)_statusCode != 200) |
| | 14741 | | { |
| 0 | 14742 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 14743 | | try |
| | 14744 | | { |
| 0 | 14745 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 14746 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 14747 | | if (_errorBody != null) |
| | 14748 | | { |
| 0 | 14749 | | ex.Body = _errorBody; |
| | 14750 | | } |
| 0 | 14751 | | } |
| 0 | 14752 | | catch (JsonException) |
| | 14753 | | { |
| | 14754 | | // Ignore the exception |
| 0 | 14755 | | } |
| 0 | 14756 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 14757 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 14758 | | if (_shouldTrace) |
| | 14759 | | { |
| 0 | 14760 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 14761 | | } |
| 0 | 14762 | | _httpRequest.Dispose(); |
| 0 | 14763 | | if (_httpResponse != null) |
| | 14764 | | { |
| 0 | 14765 | | _httpResponse.Dispose(); |
| | 14766 | | } |
| 0 | 14767 | | throw ex; |
| | 14768 | | } |
| | 14769 | | // Create Result |
| 1 | 14770 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 14771 | | _result.Request = _httpRequest; |
| 1 | 14772 | | _result.Response = _httpResponse; |
| | 14773 | | // Deserialize Response |
| 1 | 14774 | | if ((int)_statusCode == 200) |
| | 14775 | | { |
| 1 | 14776 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 14777 | | try |
| | 14778 | | { |
| 1 | 14779 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 14780 | | } |
| 0 | 14781 | | catch (JsonException ex) |
| | 14782 | | { |
| 0 | 14783 | | _httpRequest.Dispose(); |
| 0 | 14784 | | if (_httpResponse != null) |
| | 14785 | | { |
| 0 | 14786 | | _httpResponse.Dispose(); |
| | 14787 | | } |
| 0 | 14788 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 14789 | | } |
| | 14790 | | } |
| 1 | 14791 | | if (_shouldTrace) |
| | 14792 | | { |
| 0 | 14793 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 14794 | | } |
| 1 | 14795 | | return _result; |
| 1 | 14796 | | } |
| | 14797 | |
|
| | 14798 | | /// <summary> |
| | 14799 | | /// Delete an entity role in a version of the application. |
| | 14800 | | /// </summary> |
| | 14801 | | /// <param name='appId'> |
| | 14802 | | /// The application ID. |
| | 14803 | | /// </param> |
| | 14804 | | /// <param name='versionId'> |
| | 14805 | | /// The version ID. |
| | 14806 | | /// </param> |
| | 14807 | | /// <param name='entityId'> |
| | 14808 | | /// The entity ID. |
| | 14809 | | /// </param> |
| | 14810 | | /// <param name='roleId'> |
| | 14811 | | /// The entity role Id. |
| | 14812 | | /// </param> |
| | 14813 | | /// <param name='customHeaders'> |
| | 14814 | | /// Headers that will be added to request. |
| | 14815 | | /// </param> |
| | 14816 | | /// <param name='cancellationToken'> |
| | 14817 | | /// The cancellation token. |
| | 14818 | | /// </param> |
| | 14819 | | /// <exception cref="ErrorResponseException"> |
| | 14820 | | /// Thrown when the operation returned an invalid status code |
| | 14821 | | /// </exception> |
| | 14822 | | /// <exception cref="SerializationException"> |
| | 14823 | | /// Thrown when unable to deserialize the response |
| | 14824 | | /// </exception> |
| | 14825 | | /// <exception cref="ValidationException"> |
| | 14826 | | /// Thrown when a required parameter is null |
| | 14827 | | /// </exception> |
| | 14828 | | /// <exception cref="System.ArgumentNullException"> |
| | 14829 | | /// Thrown when a required parameter is null |
| | 14830 | | /// </exception> |
| | 14831 | | /// <return> |
| | 14832 | | /// A response object containing the response body and response headers. |
| | 14833 | | /// </return> |
| | 14834 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteEntityRoleWithHttpMessagesAsync(System.Guid appI |
| | 14835 | | { |
| 1 | 14836 | | if (Client.Endpoint == null) |
| | 14837 | | { |
| 0 | 14838 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 14839 | | } |
| 1 | 14840 | | if (versionId == null) |
| | 14841 | | { |
| 0 | 14842 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 14843 | | } |
| | 14844 | | // Tracing |
| 1 | 14845 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 14846 | | string _invocationId = null; |
| 1 | 14847 | | if (_shouldTrace) |
| | 14848 | | { |
| 0 | 14849 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 14850 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 14851 | | tracingParameters.Add("appId", appId); |
| 0 | 14852 | | tracingParameters.Add("versionId", versionId); |
| 0 | 14853 | | tracingParameters.Add("entityId", entityId); |
| 0 | 14854 | | tracingParameters.Add("roleId", roleId); |
| 0 | 14855 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 14856 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteEntityRole", tracingParameters); |
| | 14857 | | } |
| | 14858 | | // Construct URL |
| 1 | 14859 | | var _baseUrl = Client.BaseUri; |
| 1 | 14860 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/entities/{ent |
| 1 | 14861 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 14862 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 14863 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 14864 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 14865 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 14866 | | // Create HTTP transport objects |
| 1 | 14867 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 14868 | | HttpResponseMessage _httpResponse = null; |
| 1 | 14869 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 1 | 14870 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 14871 | | // Set Headers |
| | 14872 | |
|
| | 14873 | |
|
| 1 | 14874 | | if (customHeaders != null) |
| | 14875 | | { |
| 0 | 14876 | | foreach(var _header in customHeaders) |
| | 14877 | | { |
| 0 | 14878 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 14879 | | { |
| 0 | 14880 | | _httpRequest.Headers.Remove(_header.Key); |
| | 14881 | | } |
| 0 | 14882 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 14883 | | } |
| | 14884 | | } |
| | 14885 | |
|
| | 14886 | | // Serialize Request |
| 1 | 14887 | | string _requestContent = null; |
| | 14888 | | // Set Credentials |
| 1 | 14889 | | if (Client.Credentials != null) |
| | 14890 | | { |
| 1 | 14891 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 14892 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 14893 | | } |
| | 14894 | | // Send Request |
| 1 | 14895 | | if (_shouldTrace) |
| | 14896 | | { |
| 0 | 14897 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 14898 | | } |
| 1 | 14899 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 14900 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 14901 | | if (_shouldTrace) |
| | 14902 | | { |
| 0 | 14903 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 14904 | | } |
| 1 | 14905 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 14906 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 14907 | | string _responseContent = null; |
| 1 | 14908 | | if ((int)_statusCode != 200) |
| | 14909 | | { |
| 0 | 14910 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 14911 | | try |
| | 14912 | | { |
| 0 | 14913 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 14914 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 14915 | | if (_errorBody != null) |
| | 14916 | | { |
| 0 | 14917 | | ex.Body = _errorBody; |
| | 14918 | | } |
| 0 | 14919 | | } |
| 0 | 14920 | | catch (JsonException) |
| | 14921 | | { |
| | 14922 | | // Ignore the exception |
| 0 | 14923 | | } |
| 0 | 14924 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 14925 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 14926 | | if (_shouldTrace) |
| | 14927 | | { |
| 0 | 14928 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 14929 | | } |
| 0 | 14930 | | _httpRequest.Dispose(); |
| 0 | 14931 | | if (_httpResponse != null) |
| | 14932 | | { |
| 0 | 14933 | | _httpResponse.Dispose(); |
| | 14934 | | } |
| 0 | 14935 | | throw ex; |
| | 14936 | | } |
| | 14937 | | // Create Result |
| 1 | 14938 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 14939 | | _result.Request = _httpRequest; |
| 1 | 14940 | | _result.Response = _httpResponse; |
| | 14941 | | // Deserialize Response |
| 1 | 14942 | | if ((int)_statusCode == 200) |
| | 14943 | | { |
| 1 | 14944 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 14945 | | try |
| | 14946 | | { |
| 1 | 14947 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 14948 | | } |
| 0 | 14949 | | catch (JsonException ex) |
| | 14950 | | { |
| 0 | 14951 | | _httpRequest.Dispose(); |
| 0 | 14952 | | if (_httpResponse != null) |
| | 14953 | | { |
| 0 | 14954 | | _httpResponse.Dispose(); |
| | 14955 | | } |
| 0 | 14956 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 14957 | | } |
| | 14958 | | } |
| 1 | 14959 | | if (_shouldTrace) |
| | 14960 | | { |
| 0 | 14961 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 14962 | | } |
| 1 | 14963 | | return _result; |
| 1 | 14964 | | } |
| | 14965 | |
|
| | 14966 | | /// <summary> |
| | 14967 | | /// Get one role for a given prebuilt entity in a version of the application |
| | 14968 | | /// </summary> |
| | 14969 | | /// <param name='appId'> |
| | 14970 | | /// The application ID. |
| | 14971 | | /// </param> |
| | 14972 | | /// <param name='versionId'> |
| | 14973 | | /// The version ID. |
| | 14974 | | /// </param> |
| | 14975 | | /// <param name='entityId'> |
| | 14976 | | /// entity ID. |
| | 14977 | | /// </param> |
| | 14978 | | /// <param name='roleId'> |
| | 14979 | | /// entity role ID. |
| | 14980 | | /// </param> |
| | 14981 | | /// <param name='customHeaders'> |
| | 14982 | | /// Headers that will be added to request. |
| | 14983 | | /// </param> |
| | 14984 | | /// <param name='cancellationToken'> |
| | 14985 | | /// The cancellation token. |
| | 14986 | | /// </param> |
| | 14987 | | /// <exception cref="ErrorResponseException"> |
| | 14988 | | /// Thrown when the operation returned an invalid status code |
| | 14989 | | /// </exception> |
| | 14990 | | /// <exception cref="SerializationException"> |
| | 14991 | | /// Thrown when unable to deserialize the response |
| | 14992 | | /// </exception> |
| | 14993 | | /// <exception cref="ValidationException"> |
| | 14994 | | /// Thrown when a required parameter is null |
| | 14995 | | /// </exception> |
| | 14996 | | /// <exception cref="System.ArgumentNullException"> |
| | 14997 | | /// Thrown when a required parameter is null |
| | 14998 | | /// </exception> |
| | 14999 | | /// <return> |
| | 15000 | | /// A response object containing the response body and response headers. |
| | 15001 | | /// </return> |
| | 15002 | | public async Task<HttpOperationResponse<EntityRole>> GetPrebuiltEntityRoleWithHttpMessagesAsync(System.Guid appI |
| | 15003 | | { |
| 2 | 15004 | | if (Client.Endpoint == null) |
| | 15005 | | { |
| 0 | 15006 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 15007 | | } |
| 2 | 15008 | | if (versionId == null) |
| | 15009 | | { |
| 0 | 15010 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 15011 | | } |
| | 15012 | | // Tracing |
| 2 | 15013 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 15014 | | string _invocationId = null; |
| 2 | 15015 | | if (_shouldTrace) |
| | 15016 | | { |
| 0 | 15017 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 15018 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 15019 | | tracingParameters.Add("appId", appId); |
| 0 | 15020 | | tracingParameters.Add("versionId", versionId); |
| 0 | 15021 | | tracingParameters.Add("entityId", entityId); |
| 0 | 15022 | | tracingParameters.Add("roleId", roleId); |
| 0 | 15023 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 15024 | | ServiceClientTracing.Enter(_invocationId, this, "GetPrebuiltEntityRole", tracingParameters); |
| | 15025 | | } |
| | 15026 | | // Construct URL |
| 2 | 15027 | | var _baseUrl = Client.BaseUri; |
| 2 | 15028 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts/{en |
| 2 | 15029 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 15030 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 15031 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 2 | 15032 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 2 | 15033 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 15034 | | // Create HTTP transport objects |
| 2 | 15035 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 15036 | | HttpResponseMessage _httpResponse = null; |
| 2 | 15037 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 15038 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 15039 | | // Set Headers |
| | 15040 | |
|
| | 15041 | |
|
| 2 | 15042 | | if (customHeaders != null) |
| | 15043 | | { |
| 0 | 15044 | | foreach(var _header in customHeaders) |
| | 15045 | | { |
| 0 | 15046 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 15047 | | { |
| 0 | 15048 | | _httpRequest.Headers.Remove(_header.Key); |
| | 15049 | | } |
| 0 | 15050 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 15051 | | } |
| | 15052 | | } |
| | 15053 | |
|
| | 15054 | | // Serialize Request |
| 2 | 15055 | | string _requestContent = null; |
| | 15056 | | // Set Credentials |
| 2 | 15057 | | if (Client.Credentials != null) |
| | 15058 | | { |
| 2 | 15059 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 15060 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 15061 | | } |
| | 15062 | | // Send Request |
| 2 | 15063 | | if (_shouldTrace) |
| | 15064 | | { |
| 0 | 15065 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 15066 | | } |
| 2 | 15067 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 15068 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 15069 | | if (_shouldTrace) |
| | 15070 | | { |
| 0 | 15071 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 15072 | | } |
| 2 | 15073 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 15074 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 15075 | | string _responseContent = null; |
| 2 | 15076 | | if ((int)_statusCode != 200) |
| | 15077 | | { |
| 0 | 15078 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 15079 | | try |
| | 15080 | | { |
| 0 | 15081 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 15082 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 15083 | | if (_errorBody != null) |
| | 15084 | | { |
| 0 | 15085 | | ex.Body = _errorBody; |
| | 15086 | | } |
| 0 | 15087 | | } |
| 0 | 15088 | | catch (JsonException) |
| | 15089 | | { |
| | 15090 | | // Ignore the exception |
| 0 | 15091 | | } |
| 0 | 15092 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 15093 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 15094 | | if (_shouldTrace) |
| | 15095 | | { |
| 0 | 15096 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 15097 | | } |
| 0 | 15098 | | _httpRequest.Dispose(); |
| 0 | 15099 | | if (_httpResponse != null) |
| | 15100 | | { |
| 0 | 15101 | | _httpResponse.Dispose(); |
| | 15102 | | } |
| 0 | 15103 | | throw ex; |
| | 15104 | | } |
| | 15105 | | // Create Result |
| 2 | 15106 | | var _result = new HttpOperationResponse<EntityRole>(); |
| 2 | 15107 | | _result.Request = _httpRequest; |
| 2 | 15108 | | _result.Response = _httpResponse; |
| | 15109 | | // Deserialize Response |
| 2 | 15110 | | if ((int)_statusCode == 200) |
| | 15111 | | { |
| 2 | 15112 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 15113 | | try |
| | 15114 | | { |
| 2 | 15115 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl |
| 2 | 15116 | | } |
| 0 | 15117 | | catch (JsonException ex) |
| | 15118 | | { |
| 0 | 15119 | | _httpRequest.Dispose(); |
| 0 | 15120 | | if (_httpResponse != null) |
| | 15121 | | { |
| 0 | 15122 | | _httpResponse.Dispose(); |
| | 15123 | | } |
| 0 | 15124 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 15125 | | } |
| | 15126 | | } |
| 2 | 15127 | | if (_shouldTrace) |
| | 15128 | | { |
| 0 | 15129 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 15130 | | } |
| 2 | 15131 | | return _result; |
| 2 | 15132 | | } |
| | 15133 | |
|
| | 15134 | | /// <summary> |
| | 15135 | | /// Update a role for a given prebuilt entity in a version of the application |
| | 15136 | | /// </summary> |
| | 15137 | | /// <param name='appId'> |
| | 15138 | | /// The application ID. |
| | 15139 | | /// </param> |
| | 15140 | | /// <param name='versionId'> |
| | 15141 | | /// The version ID. |
| | 15142 | | /// </param> |
| | 15143 | | /// <param name='entityId'> |
| | 15144 | | /// The entity ID. |
| | 15145 | | /// </param> |
| | 15146 | | /// <param name='roleId'> |
| | 15147 | | /// The entity role ID. |
| | 15148 | | /// </param> |
| | 15149 | | /// <param name='entityRoleUpdateObject'> |
| | 15150 | | /// The new entity role. |
| | 15151 | | /// </param> |
| | 15152 | | /// <param name='customHeaders'> |
| | 15153 | | /// Headers that will be added to request. |
| | 15154 | | /// </param> |
| | 15155 | | /// <param name='cancellationToken'> |
| | 15156 | | /// The cancellation token. |
| | 15157 | | /// </param> |
| | 15158 | | /// <exception cref="ErrorResponseException"> |
| | 15159 | | /// Thrown when the operation returned an invalid status code |
| | 15160 | | /// </exception> |
| | 15161 | | /// <exception cref="SerializationException"> |
| | 15162 | | /// Thrown when unable to deserialize the response |
| | 15163 | | /// </exception> |
| | 15164 | | /// <exception cref="ValidationException"> |
| | 15165 | | /// Thrown when a required parameter is null |
| | 15166 | | /// </exception> |
| | 15167 | | /// <exception cref="System.ArgumentNullException"> |
| | 15168 | | /// Thrown when a required parameter is null |
| | 15169 | | /// </exception> |
| | 15170 | | /// <return> |
| | 15171 | | /// A response object containing the response body and response headers. |
| | 15172 | | /// </return> |
| | 15173 | | public async Task<HttpOperationResponse<OperationStatus>> UpdatePrebuiltEntityRoleWithHttpMessagesAsync(System.G |
| | 15174 | | { |
| 1 | 15175 | | if (Client.Endpoint == null) |
| | 15176 | | { |
| 0 | 15177 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 15178 | | } |
| 1 | 15179 | | if (versionId == null) |
| | 15180 | | { |
| 0 | 15181 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 15182 | | } |
| 1 | 15183 | | if (entityRoleUpdateObject == null) |
| | 15184 | | { |
| 0 | 15185 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject"); |
| | 15186 | | } |
| | 15187 | | // Tracing |
| 1 | 15188 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 15189 | | string _invocationId = null; |
| 1 | 15190 | | if (_shouldTrace) |
| | 15191 | | { |
| 0 | 15192 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 15193 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 15194 | | tracingParameters.Add("appId", appId); |
| 0 | 15195 | | tracingParameters.Add("versionId", versionId); |
| 0 | 15196 | | tracingParameters.Add("entityId", entityId); |
| 0 | 15197 | | tracingParameters.Add("roleId", roleId); |
| 0 | 15198 | | tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject); |
| 0 | 15199 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 15200 | | ServiceClientTracing.Enter(_invocationId, this, "UpdatePrebuiltEntityRole", tracingParameters); |
| | 15201 | | } |
| | 15202 | | // Construct URL |
| 1 | 15203 | | var _baseUrl = Client.BaseUri; |
| 1 | 15204 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts/{en |
| 1 | 15205 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 15206 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 15207 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 15208 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 15209 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 15210 | | // Create HTTP transport objects |
| 1 | 15211 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 15212 | | HttpResponseMessage _httpResponse = null; |
| 1 | 15213 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 1 | 15214 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 15215 | | // Set Headers |
| | 15216 | |
|
| | 15217 | |
|
| 1 | 15218 | | if (customHeaders != null) |
| | 15219 | | { |
| 0 | 15220 | | foreach(var _header in customHeaders) |
| | 15221 | | { |
| 0 | 15222 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 15223 | | { |
| 0 | 15224 | | _httpRequest.Headers.Remove(_header.Key); |
| | 15225 | | } |
| 0 | 15226 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 15227 | | } |
| | 15228 | | } |
| | 15229 | |
|
| | 15230 | | // Serialize Request |
| 1 | 15231 | | string _requestContent = null; |
| 1 | 15232 | | if(entityRoleUpdateObject != null) |
| | 15233 | | { |
| 1 | 15234 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri |
| 1 | 15235 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 15236 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 15237 | | } |
| | 15238 | | // Set Credentials |
| 1 | 15239 | | if (Client.Credentials != null) |
| | 15240 | | { |
| 1 | 15241 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 15242 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 15243 | | } |
| | 15244 | | // Send Request |
| 1 | 15245 | | if (_shouldTrace) |
| | 15246 | | { |
| 0 | 15247 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 15248 | | } |
| 1 | 15249 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 15250 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 15251 | | if (_shouldTrace) |
| | 15252 | | { |
| 0 | 15253 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 15254 | | } |
| 1 | 15255 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 15256 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 15257 | | string _responseContent = null; |
| 1 | 15258 | | if ((int)_statusCode != 200) |
| | 15259 | | { |
| 0 | 15260 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 15261 | | try |
| | 15262 | | { |
| 0 | 15263 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 15264 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 15265 | | if (_errorBody != null) |
| | 15266 | | { |
| 0 | 15267 | | ex.Body = _errorBody; |
| | 15268 | | } |
| 0 | 15269 | | } |
| 0 | 15270 | | catch (JsonException) |
| | 15271 | | { |
| | 15272 | | // Ignore the exception |
| 0 | 15273 | | } |
| 0 | 15274 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 15275 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 15276 | | if (_shouldTrace) |
| | 15277 | | { |
| 0 | 15278 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 15279 | | } |
| 0 | 15280 | | _httpRequest.Dispose(); |
| 0 | 15281 | | if (_httpResponse != null) |
| | 15282 | | { |
| 0 | 15283 | | _httpResponse.Dispose(); |
| | 15284 | | } |
| 0 | 15285 | | throw ex; |
| | 15286 | | } |
| | 15287 | | // Create Result |
| 1 | 15288 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 15289 | | _result.Request = _httpRequest; |
| 1 | 15290 | | _result.Response = _httpResponse; |
| | 15291 | | // Deserialize Response |
| 1 | 15292 | | if ((int)_statusCode == 200) |
| | 15293 | | { |
| 1 | 15294 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 15295 | | try |
| | 15296 | | { |
| 1 | 15297 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 15298 | | } |
| 0 | 15299 | | catch (JsonException ex) |
| | 15300 | | { |
| 0 | 15301 | | _httpRequest.Dispose(); |
| 0 | 15302 | | if (_httpResponse != null) |
| | 15303 | | { |
| 0 | 15304 | | _httpResponse.Dispose(); |
| | 15305 | | } |
| 0 | 15306 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 15307 | | } |
| | 15308 | | } |
| 1 | 15309 | | if (_shouldTrace) |
| | 15310 | | { |
| 0 | 15311 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 15312 | | } |
| 1 | 15313 | | return _result; |
| 1 | 15314 | | } |
| | 15315 | |
|
| | 15316 | | /// <summary> |
| | 15317 | | /// Delete a role in a prebuilt entity in a version of the application. |
| | 15318 | | /// </summary> |
| | 15319 | | /// <param name='appId'> |
| | 15320 | | /// The application ID. |
| | 15321 | | /// </param> |
| | 15322 | | /// <param name='versionId'> |
| | 15323 | | /// The version ID. |
| | 15324 | | /// </param> |
| | 15325 | | /// <param name='entityId'> |
| | 15326 | | /// The entity ID. |
| | 15327 | | /// </param> |
| | 15328 | | /// <param name='roleId'> |
| | 15329 | | /// The entity role Id. |
| | 15330 | | /// </param> |
| | 15331 | | /// <param name='customHeaders'> |
| | 15332 | | /// Headers that will be added to request. |
| | 15333 | | /// </param> |
| | 15334 | | /// <param name='cancellationToken'> |
| | 15335 | | /// The cancellation token. |
| | 15336 | | /// </param> |
| | 15337 | | /// <exception cref="ErrorResponseException"> |
| | 15338 | | /// Thrown when the operation returned an invalid status code |
| | 15339 | | /// </exception> |
| | 15340 | | /// <exception cref="SerializationException"> |
| | 15341 | | /// Thrown when unable to deserialize the response |
| | 15342 | | /// </exception> |
| | 15343 | | /// <exception cref="ValidationException"> |
| | 15344 | | /// Thrown when a required parameter is null |
| | 15345 | | /// </exception> |
| | 15346 | | /// <exception cref="System.ArgumentNullException"> |
| | 15347 | | /// Thrown when a required parameter is null |
| | 15348 | | /// </exception> |
| | 15349 | | /// <return> |
| | 15350 | | /// A response object containing the response body and response headers. |
| | 15351 | | /// </return> |
| | 15352 | | public async Task<HttpOperationResponse<OperationStatus>> DeletePrebuiltEntityRoleWithHttpMessagesAsync(System.G |
| | 15353 | | { |
| 1 | 15354 | | if (Client.Endpoint == null) |
| | 15355 | | { |
| 0 | 15356 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 15357 | | } |
| 1 | 15358 | | if (versionId == null) |
| | 15359 | | { |
| 0 | 15360 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 15361 | | } |
| | 15362 | | // Tracing |
| 1 | 15363 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 15364 | | string _invocationId = null; |
| 1 | 15365 | | if (_shouldTrace) |
| | 15366 | | { |
| 0 | 15367 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 15368 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 15369 | | tracingParameters.Add("appId", appId); |
| 0 | 15370 | | tracingParameters.Add("versionId", versionId); |
| 0 | 15371 | | tracingParameters.Add("entityId", entityId); |
| 0 | 15372 | | tracingParameters.Add("roleId", roleId); |
| 0 | 15373 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 15374 | | ServiceClientTracing.Enter(_invocationId, this, "DeletePrebuiltEntityRole", tracingParameters); |
| | 15375 | | } |
| | 15376 | | // Construct URL |
| 1 | 15377 | | var _baseUrl = Client.BaseUri; |
| 1 | 15378 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/prebuilts/{en |
| 1 | 15379 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 15380 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 15381 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 15382 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 15383 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 15384 | | // Create HTTP transport objects |
| 1 | 15385 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 15386 | | HttpResponseMessage _httpResponse = null; |
| 1 | 15387 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 1 | 15388 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 15389 | | // Set Headers |
| | 15390 | |
|
| | 15391 | |
|
| 1 | 15392 | | if (customHeaders != null) |
| | 15393 | | { |
| 0 | 15394 | | foreach(var _header in customHeaders) |
| | 15395 | | { |
| 0 | 15396 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 15397 | | { |
| 0 | 15398 | | _httpRequest.Headers.Remove(_header.Key); |
| | 15399 | | } |
| 0 | 15400 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 15401 | | } |
| | 15402 | | } |
| | 15403 | |
|
| | 15404 | | // Serialize Request |
| 1 | 15405 | | string _requestContent = null; |
| | 15406 | | // Set Credentials |
| 1 | 15407 | | if (Client.Credentials != null) |
| | 15408 | | { |
| 1 | 15409 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 15410 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 15411 | | } |
| | 15412 | | // Send Request |
| 1 | 15413 | | if (_shouldTrace) |
| | 15414 | | { |
| 0 | 15415 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 15416 | | } |
| 1 | 15417 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 15418 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 15419 | | if (_shouldTrace) |
| | 15420 | | { |
| 0 | 15421 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 15422 | | } |
| 1 | 15423 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 15424 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 15425 | | string _responseContent = null; |
| 1 | 15426 | | if ((int)_statusCode != 200) |
| | 15427 | | { |
| 0 | 15428 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 15429 | | try |
| | 15430 | | { |
| 0 | 15431 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 15432 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 15433 | | if (_errorBody != null) |
| | 15434 | | { |
| 0 | 15435 | | ex.Body = _errorBody; |
| | 15436 | | } |
| 0 | 15437 | | } |
| 0 | 15438 | | catch (JsonException) |
| | 15439 | | { |
| | 15440 | | // Ignore the exception |
| 0 | 15441 | | } |
| 0 | 15442 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 15443 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 15444 | | if (_shouldTrace) |
| | 15445 | | { |
| 0 | 15446 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 15447 | | } |
| 0 | 15448 | | _httpRequest.Dispose(); |
| 0 | 15449 | | if (_httpResponse != null) |
| | 15450 | | { |
| 0 | 15451 | | _httpResponse.Dispose(); |
| | 15452 | | } |
| 0 | 15453 | | throw ex; |
| | 15454 | | } |
| | 15455 | | // Create Result |
| 1 | 15456 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 15457 | | _result.Request = _httpRequest; |
| 1 | 15458 | | _result.Response = _httpResponse; |
| | 15459 | | // Deserialize Response |
| 1 | 15460 | | if ((int)_statusCode == 200) |
| | 15461 | | { |
| 1 | 15462 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 15463 | | try |
| | 15464 | | { |
| 1 | 15465 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 15466 | | } |
| 0 | 15467 | | catch (JsonException ex) |
| | 15468 | | { |
| 0 | 15469 | | _httpRequest.Dispose(); |
| 0 | 15470 | | if (_httpResponse != null) |
| | 15471 | | { |
| 0 | 15472 | | _httpResponse.Dispose(); |
| | 15473 | | } |
| 0 | 15474 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 15475 | | } |
| | 15476 | | } |
| 1 | 15477 | | if (_shouldTrace) |
| | 15478 | | { |
| 0 | 15479 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 15480 | | } |
| 1 | 15481 | | return _result; |
| 1 | 15482 | | } |
| | 15483 | |
|
| | 15484 | | /// <summary> |
| | 15485 | | /// Get one role for a given list entity in a version of the application. |
| | 15486 | | /// </summary> |
| | 15487 | | /// <param name='appId'> |
| | 15488 | | /// The application ID. |
| | 15489 | | /// </param> |
| | 15490 | | /// <param name='versionId'> |
| | 15491 | | /// The version ID. |
| | 15492 | | /// </param> |
| | 15493 | | /// <param name='entityId'> |
| | 15494 | | /// entity ID. |
| | 15495 | | /// </param> |
| | 15496 | | /// <param name='roleId'> |
| | 15497 | | /// entity role ID. |
| | 15498 | | /// </param> |
| | 15499 | | /// <param name='customHeaders'> |
| | 15500 | | /// Headers that will be added to request. |
| | 15501 | | /// </param> |
| | 15502 | | /// <param name='cancellationToken'> |
| | 15503 | | /// The cancellation token. |
| | 15504 | | /// </param> |
| | 15505 | | /// <exception cref="ErrorResponseException"> |
| | 15506 | | /// Thrown when the operation returned an invalid status code |
| | 15507 | | /// </exception> |
| | 15508 | | /// <exception cref="SerializationException"> |
| | 15509 | | /// Thrown when unable to deserialize the response |
| | 15510 | | /// </exception> |
| | 15511 | | /// <exception cref="ValidationException"> |
| | 15512 | | /// Thrown when a required parameter is null |
| | 15513 | | /// </exception> |
| | 15514 | | /// <exception cref="System.ArgumentNullException"> |
| | 15515 | | /// Thrown when a required parameter is null |
| | 15516 | | /// </exception> |
| | 15517 | | /// <return> |
| | 15518 | | /// A response object containing the response body and response headers. |
| | 15519 | | /// </return> |
| | 15520 | | public async Task<HttpOperationResponse<EntityRole>> GetClosedListEntityRoleWithHttpMessagesAsync(System.Guid ap |
| | 15521 | | { |
| 2 | 15522 | | if (Client.Endpoint == null) |
| | 15523 | | { |
| 0 | 15524 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 15525 | | } |
| 2 | 15526 | | if (versionId == null) |
| | 15527 | | { |
| 0 | 15528 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 15529 | | } |
| | 15530 | | // Tracing |
| 2 | 15531 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 15532 | | string _invocationId = null; |
| 2 | 15533 | | if (_shouldTrace) |
| | 15534 | | { |
| 0 | 15535 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 15536 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 15537 | | tracingParameters.Add("appId", appId); |
| 0 | 15538 | | tracingParameters.Add("versionId", versionId); |
| 0 | 15539 | | tracingParameters.Add("entityId", entityId); |
| 0 | 15540 | | tracingParameters.Add("roleId", roleId); |
| 0 | 15541 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 15542 | | ServiceClientTracing.Enter(_invocationId, this, "GetClosedListEntityRole", tracingParameters); |
| | 15543 | | } |
| | 15544 | | // Construct URL |
| 2 | 15545 | | var _baseUrl = Client.BaseUri; |
| 2 | 15546 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{ |
| 2 | 15547 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 15548 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 15549 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 2 | 15550 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 2 | 15551 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 15552 | | // Create HTTP transport objects |
| 2 | 15553 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 15554 | | HttpResponseMessage _httpResponse = null; |
| 2 | 15555 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 15556 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 15557 | | // Set Headers |
| | 15558 | |
|
| | 15559 | |
|
| 2 | 15560 | | if (customHeaders != null) |
| | 15561 | | { |
| 0 | 15562 | | foreach(var _header in customHeaders) |
| | 15563 | | { |
| 0 | 15564 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 15565 | | { |
| 0 | 15566 | | _httpRequest.Headers.Remove(_header.Key); |
| | 15567 | | } |
| 0 | 15568 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 15569 | | } |
| | 15570 | | } |
| | 15571 | |
|
| | 15572 | | // Serialize Request |
| 2 | 15573 | | string _requestContent = null; |
| | 15574 | | // Set Credentials |
| 2 | 15575 | | if (Client.Credentials != null) |
| | 15576 | | { |
| 2 | 15577 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 15578 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 15579 | | } |
| | 15580 | | // Send Request |
| 2 | 15581 | | if (_shouldTrace) |
| | 15582 | | { |
| 0 | 15583 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 15584 | | } |
| 2 | 15585 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 15586 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 15587 | | if (_shouldTrace) |
| | 15588 | | { |
| 0 | 15589 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 15590 | | } |
| 2 | 15591 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 15592 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 15593 | | string _responseContent = null; |
| 2 | 15594 | | if ((int)_statusCode != 200) |
| | 15595 | | { |
| 0 | 15596 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 15597 | | try |
| | 15598 | | { |
| 0 | 15599 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 15600 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 15601 | | if (_errorBody != null) |
| | 15602 | | { |
| 0 | 15603 | | ex.Body = _errorBody; |
| | 15604 | | } |
| 0 | 15605 | | } |
| 0 | 15606 | | catch (JsonException) |
| | 15607 | | { |
| | 15608 | | // Ignore the exception |
| 0 | 15609 | | } |
| 0 | 15610 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 15611 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 15612 | | if (_shouldTrace) |
| | 15613 | | { |
| 0 | 15614 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 15615 | | } |
| 0 | 15616 | | _httpRequest.Dispose(); |
| 0 | 15617 | | if (_httpResponse != null) |
| | 15618 | | { |
| 0 | 15619 | | _httpResponse.Dispose(); |
| | 15620 | | } |
| 0 | 15621 | | throw ex; |
| | 15622 | | } |
| | 15623 | | // Create Result |
| 2 | 15624 | | var _result = new HttpOperationResponse<EntityRole>(); |
| 2 | 15625 | | _result.Request = _httpRequest; |
| 2 | 15626 | | _result.Response = _httpResponse; |
| | 15627 | | // Deserialize Response |
| 2 | 15628 | | if ((int)_statusCode == 200) |
| | 15629 | | { |
| 2 | 15630 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 15631 | | try |
| | 15632 | | { |
| 2 | 15633 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl |
| 2 | 15634 | | } |
| 0 | 15635 | | catch (JsonException ex) |
| | 15636 | | { |
| 0 | 15637 | | _httpRequest.Dispose(); |
| 0 | 15638 | | if (_httpResponse != null) |
| | 15639 | | { |
| 0 | 15640 | | _httpResponse.Dispose(); |
| | 15641 | | } |
| 0 | 15642 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 15643 | | } |
| | 15644 | | } |
| 2 | 15645 | | if (_shouldTrace) |
| | 15646 | | { |
| 0 | 15647 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 15648 | | } |
| 2 | 15649 | | return _result; |
| 2 | 15650 | | } |
| | 15651 | |
|
| | 15652 | | /// <summary> |
| | 15653 | | /// Update a role for a given list entity in a version of the application. |
| | 15654 | | /// </summary> |
| | 15655 | | /// <param name='appId'> |
| | 15656 | | /// The application ID. |
| | 15657 | | /// </param> |
| | 15658 | | /// <param name='versionId'> |
| | 15659 | | /// The version ID. |
| | 15660 | | /// </param> |
| | 15661 | | /// <param name='entityId'> |
| | 15662 | | /// The entity ID. |
| | 15663 | | /// </param> |
| | 15664 | | /// <param name='roleId'> |
| | 15665 | | /// The entity role ID. |
| | 15666 | | /// </param> |
| | 15667 | | /// <param name='entityRoleUpdateObject'> |
| | 15668 | | /// The new entity role. |
| | 15669 | | /// </param> |
| | 15670 | | /// <param name='customHeaders'> |
| | 15671 | | /// Headers that will be added to request. |
| | 15672 | | /// </param> |
| | 15673 | | /// <param name='cancellationToken'> |
| | 15674 | | /// The cancellation token. |
| | 15675 | | /// </param> |
| | 15676 | | /// <exception cref="ErrorResponseException"> |
| | 15677 | | /// Thrown when the operation returned an invalid status code |
| | 15678 | | /// </exception> |
| | 15679 | | /// <exception cref="SerializationException"> |
| | 15680 | | /// Thrown when unable to deserialize the response |
| | 15681 | | /// </exception> |
| | 15682 | | /// <exception cref="ValidationException"> |
| | 15683 | | /// Thrown when a required parameter is null |
| | 15684 | | /// </exception> |
| | 15685 | | /// <exception cref="System.ArgumentNullException"> |
| | 15686 | | /// Thrown when a required parameter is null |
| | 15687 | | /// </exception> |
| | 15688 | | /// <return> |
| | 15689 | | /// A response object containing the response body and response headers. |
| | 15690 | | /// </return> |
| | 15691 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateClosedListEntityRoleWithHttpMessagesAsync(System |
| | 15692 | | { |
| 1 | 15693 | | if (Client.Endpoint == null) |
| | 15694 | | { |
| 0 | 15695 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 15696 | | } |
| 1 | 15697 | | if (versionId == null) |
| | 15698 | | { |
| 0 | 15699 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 15700 | | } |
| 1 | 15701 | | if (entityRoleUpdateObject == null) |
| | 15702 | | { |
| 0 | 15703 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject"); |
| | 15704 | | } |
| | 15705 | | // Tracing |
| 1 | 15706 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 15707 | | string _invocationId = null; |
| 1 | 15708 | | if (_shouldTrace) |
| | 15709 | | { |
| 0 | 15710 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 15711 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 15712 | | tracingParameters.Add("appId", appId); |
| 0 | 15713 | | tracingParameters.Add("versionId", versionId); |
| 0 | 15714 | | tracingParameters.Add("entityId", entityId); |
| 0 | 15715 | | tracingParameters.Add("roleId", roleId); |
| 0 | 15716 | | tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject); |
| 0 | 15717 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 15718 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateClosedListEntityRole", tracingParameters); |
| | 15719 | | } |
| | 15720 | | // Construct URL |
| 1 | 15721 | | var _baseUrl = Client.BaseUri; |
| 1 | 15722 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{ |
| 1 | 15723 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 15724 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 15725 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 15726 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 15727 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 15728 | | // Create HTTP transport objects |
| 1 | 15729 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 15730 | | HttpResponseMessage _httpResponse = null; |
| 1 | 15731 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 1 | 15732 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 15733 | | // Set Headers |
| | 15734 | |
|
| | 15735 | |
|
| 1 | 15736 | | if (customHeaders != null) |
| | 15737 | | { |
| 0 | 15738 | | foreach(var _header in customHeaders) |
| | 15739 | | { |
| 0 | 15740 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 15741 | | { |
| 0 | 15742 | | _httpRequest.Headers.Remove(_header.Key); |
| | 15743 | | } |
| 0 | 15744 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 15745 | | } |
| | 15746 | | } |
| | 15747 | |
|
| | 15748 | | // Serialize Request |
| 1 | 15749 | | string _requestContent = null; |
| 1 | 15750 | | if(entityRoleUpdateObject != null) |
| | 15751 | | { |
| 1 | 15752 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri |
| 1 | 15753 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 15754 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 15755 | | } |
| | 15756 | | // Set Credentials |
| 1 | 15757 | | if (Client.Credentials != null) |
| | 15758 | | { |
| 1 | 15759 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 15760 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 15761 | | } |
| | 15762 | | // Send Request |
| 1 | 15763 | | if (_shouldTrace) |
| | 15764 | | { |
| 0 | 15765 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 15766 | | } |
| 1 | 15767 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 15768 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 15769 | | if (_shouldTrace) |
| | 15770 | | { |
| 0 | 15771 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 15772 | | } |
| 1 | 15773 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 15774 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 15775 | | string _responseContent = null; |
| 1 | 15776 | | if ((int)_statusCode != 200) |
| | 15777 | | { |
| 0 | 15778 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 15779 | | try |
| | 15780 | | { |
| 0 | 15781 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 15782 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 15783 | | if (_errorBody != null) |
| | 15784 | | { |
| 0 | 15785 | | ex.Body = _errorBody; |
| | 15786 | | } |
| 0 | 15787 | | } |
| 0 | 15788 | | catch (JsonException) |
| | 15789 | | { |
| | 15790 | | // Ignore the exception |
| 0 | 15791 | | } |
| 0 | 15792 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 15793 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 15794 | | if (_shouldTrace) |
| | 15795 | | { |
| 0 | 15796 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 15797 | | } |
| 0 | 15798 | | _httpRequest.Dispose(); |
| 0 | 15799 | | if (_httpResponse != null) |
| | 15800 | | { |
| 0 | 15801 | | _httpResponse.Dispose(); |
| | 15802 | | } |
| 0 | 15803 | | throw ex; |
| | 15804 | | } |
| | 15805 | | // Create Result |
| 1 | 15806 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 15807 | | _result.Request = _httpRequest; |
| 1 | 15808 | | _result.Response = _httpResponse; |
| | 15809 | | // Deserialize Response |
| 1 | 15810 | | if ((int)_statusCode == 200) |
| | 15811 | | { |
| 1 | 15812 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 15813 | | try |
| | 15814 | | { |
| 1 | 15815 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 15816 | | } |
| 0 | 15817 | | catch (JsonException ex) |
| | 15818 | | { |
| 0 | 15819 | | _httpRequest.Dispose(); |
| 0 | 15820 | | if (_httpResponse != null) |
| | 15821 | | { |
| 0 | 15822 | | _httpResponse.Dispose(); |
| | 15823 | | } |
| 0 | 15824 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 15825 | | } |
| | 15826 | | } |
| 1 | 15827 | | if (_shouldTrace) |
| | 15828 | | { |
| 0 | 15829 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 15830 | | } |
| 1 | 15831 | | return _result; |
| 1 | 15832 | | } |
| | 15833 | |
|
| | 15834 | | /// <summary> |
| | 15835 | | /// Delete a role for a given list entity in a version of the application. |
| | 15836 | | /// </summary> |
| | 15837 | | /// <param name='appId'> |
| | 15838 | | /// The application ID. |
| | 15839 | | /// </param> |
| | 15840 | | /// <param name='versionId'> |
| | 15841 | | /// The version ID. |
| | 15842 | | /// </param> |
| | 15843 | | /// <param name='entityId'> |
| | 15844 | | /// The entity ID. |
| | 15845 | | /// </param> |
| | 15846 | | /// <param name='roleId'> |
| | 15847 | | /// The entity role Id. |
| | 15848 | | /// </param> |
| | 15849 | | /// <param name='customHeaders'> |
| | 15850 | | /// Headers that will be added to request. |
| | 15851 | | /// </param> |
| | 15852 | | /// <param name='cancellationToken'> |
| | 15853 | | /// The cancellation token. |
| | 15854 | | /// </param> |
| | 15855 | | /// <exception cref="ErrorResponseException"> |
| | 15856 | | /// Thrown when the operation returned an invalid status code |
| | 15857 | | /// </exception> |
| | 15858 | | /// <exception cref="SerializationException"> |
| | 15859 | | /// Thrown when unable to deserialize the response |
| | 15860 | | /// </exception> |
| | 15861 | | /// <exception cref="ValidationException"> |
| | 15862 | | /// Thrown when a required parameter is null |
| | 15863 | | /// </exception> |
| | 15864 | | /// <exception cref="System.ArgumentNullException"> |
| | 15865 | | /// Thrown when a required parameter is null |
| | 15866 | | /// </exception> |
| | 15867 | | /// <return> |
| | 15868 | | /// A response object containing the response body and response headers. |
| | 15869 | | /// </return> |
| | 15870 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteClosedListEntityRoleWithHttpMessagesAsync(System |
| | 15871 | | { |
| 1 | 15872 | | if (Client.Endpoint == null) |
| | 15873 | | { |
| 0 | 15874 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 15875 | | } |
| 1 | 15876 | | if (versionId == null) |
| | 15877 | | { |
| 0 | 15878 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 15879 | | } |
| | 15880 | | // Tracing |
| 1 | 15881 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 15882 | | string _invocationId = null; |
| 1 | 15883 | | if (_shouldTrace) |
| | 15884 | | { |
| 0 | 15885 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 15886 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 15887 | | tracingParameters.Add("appId", appId); |
| 0 | 15888 | | tracingParameters.Add("versionId", versionId); |
| 0 | 15889 | | tracingParameters.Add("entityId", entityId); |
| 0 | 15890 | | tracingParameters.Add("roleId", roleId); |
| 0 | 15891 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 15892 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteClosedListEntityRole", tracingParameters); |
| | 15893 | | } |
| | 15894 | | // Construct URL |
| 1 | 15895 | | var _baseUrl = Client.BaseUri; |
| 1 | 15896 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/closedlists/{ |
| 1 | 15897 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 15898 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 15899 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 15900 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 15901 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 15902 | | // Create HTTP transport objects |
| 1 | 15903 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 15904 | | HttpResponseMessage _httpResponse = null; |
| 1 | 15905 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 1 | 15906 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 15907 | | // Set Headers |
| | 15908 | |
|
| | 15909 | |
|
| 1 | 15910 | | if (customHeaders != null) |
| | 15911 | | { |
| 0 | 15912 | | foreach(var _header in customHeaders) |
| | 15913 | | { |
| 0 | 15914 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 15915 | | { |
| 0 | 15916 | | _httpRequest.Headers.Remove(_header.Key); |
| | 15917 | | } |
| 0 | 15918 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 15919 | | } |
| | 15920 | | } |
| | 15921 | |
|
| | 15922 | | // Serialize Request |
| 1 | 15923 | | string _requestContent = null; |
| | 15924 | | // Set Credentials |
| 1 | 15925 | | if (Client.Credentials != null) |
| | 15926 | | { |
| 1 | 15927 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 15928 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 15929 | | } |
| | 15930 | | // Send Request |
| 1 | 15931 | | if (_shouldTrace) |
| | 15932 | | { |
| 0 | 15933 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 15934 | | } |
| 1 | 15935 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 15936 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 15937 | | if (_shouldTrace) |
| | 15938 | | { |
| 0 | 15939 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 15940 | | } |
| 1 | 15941 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 15942 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 15943 | | string _responseContent = null; |
| 1 | 15944 | | if ((int)_statusCode != 200) |
| | 15945 | | { |
| 0 | 15946 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 15947 | | try |
| | 15948 | | { |
| 0 | 15949 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 15950 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 15951 | | if (_errorBody != null) |
| | 15952 | | { |
| 0 | 15953 | | ex.Body = _errorBody; |
| | 15954 | | } |
| 0 | 15955 | | } |
| 0 | 15956 | | catch (JsonException) |
| | 15957 | | { |
| | 15958 | | // Ignore the exception |
| 0 | 15959 | | } |
| 0 | 15960 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 15961 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 15962 | | if (_shouldTrace) |
| | 15963 | | { |
| 0 | 15964 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 15965 | | } |
| 0 | 15966 | | _httpRequest.Dispose(); |
| 0 | 15967 | | if (_httpResponse != null) |
| | 15968 | | { |
| 0 | 15969 | | _httpResponse.Dispose(); |
| | 15970 | | } |
| 0 | 15971 | | throw ex; |
| | 15972 | | } |
| | 15973 | | // Create Result |
| 1 | 15974 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 15975 | | _result.Request = _httpRequest; |
| 1 | 15976 | | _result.Response = _httpResponse; |
| | 15977 | | // Deserialize Response |
| 1 | 15978 | | if ((int)_statusCode == 200) |
| | 15979 | | { |
| 1 | 15980 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 15981 | | try |
| | 15982 | | { |
| 1 | 15983 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 15984 | | } |
| 0 | 15985 | | catch (JsonException ex) |
| | 15986 | | { |
| 0 | 15987 | | _httpRequest.Dispose(); |
| 0 | 15988 | | if (_httpResponse != null) |
| | 15989 | | { |
| 0 | 15990 | | _httpResponse.Dispose(); |
| | 15991 | | } |
| 0 | 15992 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 15993 | | } |
| | 15994 | | } |
| 1 | 15995 | | if (_shouldTrace) |
| | 15996 | | { |
| 0 | 15997 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 15998 | | } |
| 1 | 15999 | | return _result; |
| 1 | 16000 | | } |
| | 16001 | |
|
| | 16002 | | /// <summary> |
| | 16003 | | /// Get one role for a given regular expression entity in a version of the |
| | 16004 | | /// application. |
| | 16005 | | /// </summary> |
| | 16006 | | /// <param name='appId'> |
| | 16007 | | /// The application ID. |
| | 16008 | | /// </param> |
| | 16009 | | /// <param name='versionId'> |
| | 16010 | | /// The version ID. |
| | 16011 | | /// </param> |
| | 16012 | | /// <param name='entityId'> |
| | 16013 | | /// entity ID. |
| | 16014 | | /// </param> |
| | 16015 | | /// <param name='roleId'> |
| | 16016 | | /// entity role ID. |
| | 16017 | | /// </param> |
| | 16018 | | /// <param name='customHeaders'> |
| | 16019 | | /// Headers that will be added to request. |
| | 16020 | | /// </param> |
| | 16021 | | /// <param name='cancellationToken'> |
| | 16022 | | /// The cancellation token. |
| | 16023 | | /// </param> |
| | 16024 | | /// <exception cref="ErrorResponseException"> |
| | 16025 | | /// Thrown when the operation returned an invalid status code |
| | 16026 | | /// </exception> |
| | 16027 | | /// <exception cref="SerializationException"> |
| | 16028 | | /// Thrown when unable to deserialize the response |
| | 16029 | | /// </exception> |
| | 16030 | | /// <exception cref="ValidationException"> |
| | 16031 | | /// Thrown when a required parameter is null |
| | 16032 | | /// </exception> |
| | 16033 | | /// <exception cref="System.ArgumentNullException"> |
| | 16034 | | /// Thrown when a required parameter is null |
| | 16035 | | /// </exception> |
| | 16036 | | /// <return> |
| | 16037 | | /// A response object containing the response body and response headers. |
| | 16038 | | /// </return> |
| | 16039 | | public async Task<HttpOperationResponse<EntityRole>> GetRegexEntityRoleWithHttpMessagesAsync(System.Guid appId, |
| | 16040 | | { |
| 2 | 16041 | | if (Client.Endpoint == null) |
| | 16042 | | { |
| 0 | 16043 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 16044 | | } |
| 2 | 16045 | | if (versionId == null) |
| | 16046 | | { |
| 0 | 16047 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 16048 | | } |
| | 16049 | | // Tracing |
| 2 | 16050 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 16051 | | string _invocationId = null; |
| 2 | 16052 | | if (_shouldTrace) |
| | 16053 | | { |
| 0 | 16054 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 16055 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 16056 | | tracingParameters.Add("appId", appId); |
| 0 | 16057 | | tracingParameters.Add("versionId", versionId); |
| 0 | 16058 | | tracingParameters.Add("entityId", entityId); |
| 0 | 16059 | | tracingParameters.Add("roleId", roleId); |
| 0 | 16060 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 16061 | | ServiceClientTracing.Enter(_invocationId, this, "GetRegexEntityRole", tracingParameters); |
| | 16062 | | } |
| | 16063 | | // Construct URL |
| 2 | 16064 | | var _baseUrl = Client.BaseUri; |
| 2 | 16065 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities |
| 2 | 16066 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 16067 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 16068 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 2 | 16069 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 2 | 16070 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 16071 | | // Create HTTP transport objects |
| 2 | 16072 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 16073 | | HttpResponseMessage _httpResponse = null; |
| 2 | 16074 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 16075 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 16076 | | // Set Headers |
| | 16077 | |
|
| | 16078 | |
|
| 2 | 16079 | | if (customHeaders != null) |
| | 16080 | | { |
| 0 | 16081 | | foreach(var _header in customHeaders) |
| | 16082 | | { |
| 0 | 16083 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 16084 | | { |
| 0 | 16085 | | _httpRequest.Headers.Remove(_header.Key); |
| | 16086 | | } |
| 0 | 16087 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 16088 | | } |
| | 16089 | | } |
| | 16090 | |
|
| | 16091 | | // Serialize Request |
| 2 | 16092 | | string _requestContent = null; |
| | 16093 | | // Set Credentials |
| 2 | 16094 | | if (Client.Credentials != null) |
| | 16095 | | { |
| 2 | 16096 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 16097 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 16098 | | } |
| | 16099 | | // Send Request |
| 2 | 16100 | | if (_shouldTrace) |
| | 16101 | | { |
| 0 | 16102 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 16103 | | } |
| 2 | 16104 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 16105 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 16106 | | if (_shouldTrace) |
| | 16107 | | { |
| 0 | 16108 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 16109 | | } |
| 2 | 16110 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 16111 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 16112 | | string _responseContent = null; |
| 2 | 16113 | | if ((int)_statusCode != 200) |
| | 16114 | | { |
| 0 | 16115 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 16116 | | try |
| | 16117 | | { |
| 0 | 16118 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 16119 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 16120 | | if (_errorBody != null) |
| | 16121 | | { |
| 0 | 16122 | | ex.Body = _errorBody; |
| | 16123 | | } |
| 0 | 16124 | | } |
| 0 | 16125 | | catch (JsonException) |
| | 16126 | | { |
| | 16127 | | // Ignore the exception |
| 0 | 16128 | | } |
| 0 | 16129 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 16130 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 16131 | | if (_shouldTrace) |
| | 16132 | | { |
| 0 | 16133 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 16134 | | } |
| 0 | 16135 | | _httpRequest.Dispose(); |
| 0 | 16136 | | if (_httpResponse != null) |
| | 16137 | | { |
| 0 | 16138 | | _httpResponse.Dispose(); |
| | 16139 | | } |
| 0 | 16140 | | throw ex; |
| | 16141 | | } |
| | 16142 | | // Create Result |
| 2 | 16143 | | var _result = new HttpOperationResponse<EntityRole>(); |
| 2 | 16144 | | _result.Request = _httpRequest; |
| 2 | 16145 | | _result.Response = _httpResponse; |
| | 16146 | | // Deserialize Response |
| 2 | 16147 | | if ((int)_statusCode == 200) |
| | 16148 | | { |
| 2 | 16149 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 16150 | | try |
| | 16151 | | { |
| 2 | 16152 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl |
| 2 | 16153 | | } |
| 0 | 16154 | | catch (JsonException ex) |
| | 16155 | | { |
| 0 | 16156 | | _httpRequest.Dispose(); |
| 0 | 16157 | | if (_httpResponse != null) |
| | 16158 | | { |
| 0 | 16159 | | _httpResponse.Dispose(); |
| | 16160 | | } |
| 0 | 16161 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 16162 | | } |
| | 16163 | | } |
| 2 | 16164 | | if (_shouldTrace) |
| | 16165 | | { |
| 0 | 16166 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 16167 | | } |
| 2 | 16168 | | return _result; |
| 2 | 16169 | | } |
| | 16170 | |
|
| | 16171 | | /// <summary> |
| | 16172 | | /// Update a role for a given regular expression entity in a version of the |
| | 16173 | | /// application |
| | 16174 | | /// </summary> |
| | 16175 | | /// <param name='appId'> |
| | 16176 | | /// The application ID. |
| | 16177 | | /// </param> |
| | 16178 | | /// <param name='versionId'> |
| | 16179 | | /// The version ID. |
| | 16180 | | /// </param> |
| | 16181 | | /// <param name='entityId'> |
| | 16182 | | /// The entity ID. |
| | 16183 | | /// </param> |
| | 16184 | | /// <param name='roleId'> |
| | 16185 | | /// The entity role ID. |
| | 16186 | | /// </param> |
| | 16187 | | /// <param name='entityRoleUpdateObject'> |
| | 16188 | | /// The new entity role. |
| | 16189 | | /// </param> |
| | 16190 | | /// <param name='customHeaders'> |
| | 16191 | | /// Headers that will be added to request. |
| | 16192 | | /// </param> |
| | 16193 | | /// <param name='cancellationToken'> |
| | 16194 | | /// The cancellation token. |
| | 16195 | | /// </param> |
| | 16196 | | /// <exception cref="ErrorResponseException"> |
| | 16197 | | /// Thrown when the operation returned an invalid status code |
| | 16198 | | /// </exception> |
| | 16199 | | /// <exception cref="SerializationException"> |
| | 16200 | | /// Thrown when unable to deserialize the response |
| | 16201 | | /// </exception> |
| | 16202 | | /// <exception cref="ValidationException"> |
| | 16203 | | /// Thrown when a required parameter is null |
| | 16204 | | /// </exception> |
| | 16205 | | /// <exception cref="System.ArgumentNullException"> |
| | 16206 | | /// Thrown when a required parameter is null |
| | 16207 | | /// </exception> |
| | 16208 | | /// <return> |
| | 16209 | | /// A response object containing the response body and response headers. |
| | 16210 | | /// </return> |
| | 16211 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateRegexEntityRoleWithHttpMessagesAsync(System.Guid |
| | 16212 | | { |
| 1 | 16213 | | if (Client.Endpoint == null) |
| | 16214 | | { |
| 0 | 16215 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 16216 | | } |
| 1 | 16217 | | if (versionId == null) |
| | 16218 | | { |
| 0 | 16219 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 16220 | | } |
| 1 | 16221 | | if (entityRoleUpdateObject == null) |
| | 16222 | | { |
| 0 | 16223 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject"); |
| | 16224 | | } |
| | 16225 | | // Tracing |
| 1 | 16226 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 16227 | | string _invocationId = null; |
| 1 | 16228 | | if (_shouldTrace) |
| | 16229 | | { |
| 0 | 16230 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 16231 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 16232 | | tracingParameters.Add("appId", appId); |
| 0 | 16233 | | tracingParameters.Add("versionId", versionId); |
| 0 | 16234 | | tracingParameters.Add("entityId", entityId); |
| 0 | 16235 | | tracingParameters.Add("roleId", roleId); |
| 0 | 16236 | | tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject); |
| 0 | 16237 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 16238 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateRegexEntityRole", tracingParameters); |
| | 16239 | | } |
| | 16240 | | // Construct URL |
| 1 | 16241 | | var _baseUrl = Client.BaseUri; |
| 1 | 16242 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities |
| 1 | 16243 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 16244 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 16245 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 16246 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 16247 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 16248 | | // Create HTTP transport objects |
| 1 | 16249 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 16250 | | HttpResponseMessage _httpResponse = null; |
| 1 | 16251 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 1 | 16252 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 16253 | | // Set Headers |
| | 16254 | |
|
| | 16255 | |
|
| 1 | 16256 | | if (customHeaders != null) |
| | 16257 | | { |
| 0 | 16258 | | foreach(var _header in customHeaders) |
| | 16259 | | { |
| 0 | 16260 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 16261 | | { |
| 0 | 16262 | | _httpRequest.Headers.Remove(_header.Key); |
| | 16263 | | } |
| 0 | 16264 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 16265 | | } |
| | 16266 | | } |
| | 16267 | |
|
| | 16268 | | // Serialize Request |
| 1 | 16269 | | string _requestContent = null; |
| 1 | 16270 | | if(entityRoleUpdateObject != null) |
| | 16271 | | { |
| 1 | 16272 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri |
| 1 | 16273 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 16274 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 16275 | | } |
| | 16276 | | // Set Credentials |
| 1 | 16277 | | if (Client.Credentials != null) |
| | 16278 | | { |
| 1 | 16279 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 16280 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 16281 | | } |
| | 16282 | | // Send Request |
| 1 | 16283 | | if (_shouldTrace) |
| | 16284 | | { |
| 0 | 16285 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 16286 | | } |
| 1 | 16287 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 16288 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 16289 | | if (_shouldTrace) |
| | 16290 | | { |
| 0 | 16291 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 16292 | | } |
| 1 | 16293 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 16294 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 16295 | | string _responseContent = null; |
| 1 | 16296 | | if ((int)_statusCode != 200) |
| | 16297 | | { |
| 0 | 16298 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 16299 | | try |
| | 16300 | | { |
| 0 | 16301 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 16302 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 16303 | | if (_errorBody != null) |
| | 16304 | | { |
| 0 | 16305 | | ex.Body = _errorBody; |
| | 16306 | | } |
| 0 | 16307 | | } |
| 0 | 16308 | | catch (JsonException) |
| | 16309 | | { |
| | 16310 | | // Ignore the exception |
| 0 | 16311 | | } |
| 0 | 16312 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 16313 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 16314 | | if (_shouldTrace) |
| | 16315 | | { |
| 0 | 16316 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 16317 | | } |
| 0 | 16318 | | _httpRequest.Dispose(); |
| 0 | 16319 | | if (_httpResponse != null) |
| | 16320 | | { |
| 0 | 16321 | | _httpResponse.Dispose(); |
| | 16322 | | } |
| 0 | 16323 | | throw ex; |
| | 16324 | | } |
| | 16325 | | // Create Result |
| 1 | 16326 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 16327 | | _result.Request = _httpRequest; |
| 1 | 16328 | | _result.Response = _httpResponse; |
| | 16329 | | // Deserialize Response |
| 1 | 16330 | | if ((int)_statusCode == 200) |
| | 16331 | | { |
| 1 | 16332 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 16333 | | try |
| | 16334 | | { |
| 1 | 16335 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 16336 | | } |
| 0 | 16337 | | catch (JsonException ex) |
| | 16338 | | { |
| 0 | 16339 | | _httpRequest.Dispose(); |
| 0 | 16340 | | if (_httpResponse != null) |
| | 16341 | | { |
| 0 | 16342 | | _httpResponse.Dispose(); |
| | 16343 | | } |
| 0 | 16344 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 16345 | | } |
| | 16346 | | } |
| 1 | 16347 | | if (_shouldTrace) |
| | 16348 | | { |
| 0 | 16349 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 16350 | | } |
| 1 | 16351 | | return _result; |
| 1 | 16352 | | } |
| | 16353 | |
|
| | 16354 | | /// <summary> |
| | 16355 | | /// Delete a role for a given regular expression in a version of the |
| | 16356 | | /// application. |
| | 16357 | | /// </summary> |
| | 16358 | | /// <param name='appId'> |
| | 16359 | | /// The application ID. |
| | 16360 | | /// </param> |
| | 16361 | | /// <param name='versionId'> |
| | 16362 | | /// The version ID. |
| | 16363 | | /// </param> |
| | 16364 | | /// <param name='entityId'> |
| | 16365 | | /// The entity ID. |
| | 16366 | | /// </param> |
| | 16367 | | /// <param name='roleId'> |
| | 16368 | | /// The entity role Id. |
| | 16369 | | /// </param> |
| | 16370 | | /// <param name='customHeaders'> |
| | 16371 | | /// Headers that will be added to request. |
| | 16372 | | /// </param> |
| | 16373 | | /// <param name='cancellationToken'> |
| | 16374 | | /// The cancellation token. |
| | 16375 | | /// </param> |
| | 16376 | | /// <exception cref="ErrorResponseException"> |
| | 16377 | | /// Thrown when the operation returned an invalid status code |
| | 16378 | | /// </exception> |
| | 16379 | | /// <exception cref="SerializationException"> |
| | 16380 | | /// Thrown when unable to deserialize the response |
| | 16381 | | /// </exception> |
| | 16382 | | /// <exception cref="ValidationException"> |
| | 16383 | | /// Thrown when a required parameter is null |
| | 16384 | | /// </exception> |
| | 16385 | | /// <exception cref="System.ArgumentNullException"> |
| | 16386 | | /// Thrown when a required parameter is null |
| | 16387 | | /// </exception> |
| | 16388 | | /// <return> |
| | 16389 | | /// A response object containing the response body and response headers. |
| | 16390 | | /// </return> |
| | 16391 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteRegexEntityRoleWithHttpMessagesAsync(System.Guid |
| | 16392 | | { |
| 1 | 16393 | | if (Client.Endpoint == null) |
| | 16394 | | { |
| 0 | 16395 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 16396 | | } |
| 1 | 16397 | | if (versionId == null) |
| | 16398 | | { |
| 0 | 16399 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 16400 | | } |
| | 16401 | | // Tracing |
| 1 | 16402 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 16403 | | string _invocationId = null; |
| 1 | 16404 | | if (_shouldTrace) |
| | 16405 | | { |
| 0 | 16406 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 16407 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 16408 | | tracingParameters.Add("appId", appId); |
| 0 | 16409 | | tracingParameters.Add("versionId", versionId); |
| 0 | 16410 | | tracingParameters.Add("entityId", entityId); |
| 0 | 16411 | | tracingParameters.Add("roleId", roleId); |
| 0 | 16412 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 16413 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteRegexEntityRole", tracingParameters); |
| | 16414 | | } |
| | 16415 | | // Construct URL |
| 1 | 16416 | | var _baseUrl = Client.BaseUri; |
| 1 | 16417 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/regexentities |
| 1 | 16418 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 16419 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 16420 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 16421 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 16422 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 16423 | | // Create HTTP transport objects |
| 1 | 16424 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 16425 | | HttpResponseMessage _httpResponse = null; |
| 1 | 16426 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 1 | 16427 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 16428 | | // Set Headers |
| | 16429 | |
|
| | 16430 | |
|
| 1 | 16431 | | if (customHeaders != null) |
| | 16432 | | { |
| 0 | 16433 | | foreach(var _header in customHeaders) |
| | 16434 | | { |
| 0 | 16435 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 16436 | | { |
| 0 | 16437 | | _httpRequest.Headers.Remove(_header.Key); |
| | 16438 | | } |
| 0 | 16439 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 16440 | | } |
| | 16441 | | } |
| | 16442 | |
|
| | 16443 | | // Serialize Request |
| 1 | 16444 | | string _requestContent = null; |
| | 16445 | | // Set Credentials |
| 1 | 16446 | | if (Client.Credentials != null) |
| | 16447 | | { |
| 1 | 16448 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 16449 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 16450 | | } |
| | 16451 | | // Send Request |
| 1 | 16452 | | if (_shouldTrace) |
| | 16453 | | { |
| 0 | 16454 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 16455 | | } |
| 1 | 16456 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 16457 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 16458 | | if (_shouldTrace) |
| | 16459 | | { |
| 0 | 16460 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 16461 | | } |
| 1 | 16462 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 16463 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 16464 | | string _responseContent = null; |
| 1 | 16465 | | if ((int)_statusCode != 200) |
| | 16466 | | { |
| 0 | 16467 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 16468 | | try |
| | 16469 | | { |
| 0 | 16470 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 16471 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 16472 | | if (_errorBody != null) |
| | 16473 | | { |
| 0 | 16474 | | ex.Body = _errorBody; |
| | 16475 | | } |
| 0 | 16476 | | } |
| 0 | 16477 | | catch (JsonException) |
| | 16478 | | { |
| | 16479 | | // Ignore the exception |
| 0 | 16480 | | } |
| 0 | 16481 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 16482 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 16483 | | if (_shouldTrace) |
| | 16484 | | { |
| 0 | 16485 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 16486 | | } |
| 0 | 16487 | | _httpRequest.Dispose(); |
| 0 | 16488 | | if (_httpResponse != null) |
| | 16489 | | { |
| 0 | 16490 | | _httpResponse.Dispose(); |
| | 16491 | | } |
| 0 | 16492 | | throw ex; |
| | 16493 | | } |
| | 16494 | | // Create Result |
| 1 | 16495 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 16496 | | _result.Request = _httpRequest; |
| 1 | 16497 | | _result.Response = _httpResponse; |
| | 16498 | | // Deserialize Response |
| 1 | 16499 | | if ((int)_statusCode == 200) |
| | 16500 | | { |
| 1 | 16501 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 16502 | | try |
| | 16503 | | { |
| 1 | 16504 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 16505 | | } |
| 0 | 16506 | | catch (JsonException ex) |
| | 16507 | | { |
| 0 | 16508 | | _httpRequest.Dispose(); |
| 0 | 16509 | | if (_httpResponse != null) |
| | 16510 | | { |
| 0 | 16511 | | _httpResponse.Dispose(); |
| | 16512 | | } |
| 0 | 16513 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 16514 | | } |
| | 16515 | | } |
| 1 | 16516 | | if (_shouldTrace) |
| | 16517 | | { |
| 0 | 16518 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 16519 | | } |
| 1 | 16520 | | return _result; |
| 1 | 16521 | | } |
| | 16522 | |
|
| | 16523 | | /// <summary> |
| | 16524 | | /// Get one role for a given composite entity in a version of the application |
| | 16525 | | /// </summary> |
| | 16526 | | /// <param name='appId'> |
| | 16527 | | /// The application ID. |
| | 16528 | | /// </param> |
| | 16529 | | /// <param name='versionId'> |
| | 16530 | | /// The version ID. |
| | 16531 | | /// </param> |
| | 16532 | | /// <param name='cEntityId'> |
| | 16533 | | /// The composite entity extractor ID. |
| | 16534 | | /// </param> |
| | 16535 | | /// <param name='roleId'> |
| | 16536 | | /// entity role ID. |
| | 16537 | | /// </param> |
| | 16538 | | /// <param name='customHeaders'> |
| | 16539 | | /// Headers that will be added to request. |
| | 16540 | | /// </param> |
| | 16541 | | /// <param name='cancellationToken'> |
| | 16542 | | /// The cancellation token. |
| | 16543 | | /// </param> |
| | 16544 | | /// <exception cref="ErrorResponseException"> |
| | 16545 | | /// Thrown when the operation returned an invalid status code |
| | 16546 | | /// </exception> |
| | 16547 | | /// <exception cref="SerializationException"> |
| | 16548 | | /// Thrown when unable to deserialize the response |
| | 16549 | | /// </exception> |
| | 16550 | | /// <exception cref="ValidationException"> |
| | 16551 | | /// Thrown when a required parameter is null |
| | 16552 | | /// </exception> |
| | 16553 | | /// <exception cref="System.ArgumentNullException"> |
| | 16554 | | /// Thrown when a required parameter is null |
| | 16555 | | /// </exception> |
| | 16556 | | /// <return> |
| | 16557 | | /// A response object containing the response body and response headers. |
| | 16558 | | /// </return> |
| | 16559 | | public async Task<HttpOperationResponse<EntityRole>> GetCompositeEntityRoleWithHttpMessagesAsync(System.Guid app |
| | 16560 | | { |
| 0 | 16561 | | if (Client.Endpoint == null) |
| | 16562 | | { |
| 0 | 16563 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 16564 | | } |
| 0 | 16565 | | if (versionId == null) |
| | 16566 | | { |
| 0 | 16567 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 16568 | | } |
| | 16569 | | // Tracing |
| 0 | 16570 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 16571 | | string _invocationId = null; |
| 0 | 16572 | | if (_shouldTrace) |
| | 16573 | | { |
| 0 | 16574 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 16575 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 16576 | | tracingParameters.Add("appId", appId); |
| 0 | 16577 | | tracingParameters.Add("versionId", versionId); |
| 0 | 16578 | | tracingParameters.Add("cEntityId", cEntityId); |
| 0 | 16579 | | tracingParameters.Add("roleId", roleId); |
| 0 | 16580 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 16581 | | ServiceClientTracing.Enter(_invocationId, this, "GetCompositeEntityRole", tracingParameters); |
| | 16582 | | } |
| | 16583 | | // Construct URL |
| 0 | 16584 | | var _baseUrl = Client.BaseUri; |
| 0 | 16585 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti |
| 0 | 16586 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 16587 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 16588 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 16589 | | _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| 0 | 16590 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 16591 | | // Create HTTP transport objects |
| 0 | 16592 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 16593 | | HttpResponseMessage _httpResponse = null; |
| 0 | 16594 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 16595 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 16596 | | // Set Headers |
| | 16597 | |
|
| | 16598 | |
|
| 0 | 16599 | | if (customHeaders != null) |
| | 16600 | | { |
| 0 | 16601 | | foreach(var _header in customHeaders) |
| | 16602 | | { |
| 0 | 16603 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 16604 | | { |
| 0 | 16605 | | _httpRequest.Headers.Remove(_header.Key); |
| | 16606 | | } |
| 0 | 16607 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 16608 | | } |
| | 16609 | | } |
| | 16610 | |
|
| | 16611 | | // Serialize Request |
| 0 | 16612 | | string _requestContent = null; |
| | 16613 | | // Set Credentials |
| 0 | 16614 | | if (Client.Credentials != null) |
| | 16615 | | { |
| 0 | 16616 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 16617 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 16618 | | } |
| | 16619 | | // Send Request |
| 0 | 16620 | | if (_shouldTrace) |
| | 16621 | | { |
| 0 | 16622 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 16623 | | } |
| 0 | 16624 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 16625 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 16626 | | if (_shouldTrace) |
| | 16627 | | { |
| 0 | 16628 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 16629 | | } |
| 0 | 16630 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 16631 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 16632 | | string _responseContent = null; |
| 0 | 16633 | | if ((int)_statusCode != 200) |
| | 16634 | | { |
| 0 | 16635 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 16636 | | try |
| | 16637 | | { |
| 0 | 16638 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 16639 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 16640 | | if (_errorBody != null) |
| | 16641 | | { |
| 0 | 16642 | | ex.Body = _errorBody; |
| | 16643 | | } |
| 0 | 16644 | | } |
| 0 | 16645 | | catch (JsonException) |
| | 16646 | | { |
| | 16647 | | // Ignore the exception |
| 0 | 16648 | | } |
| 0 | 16649 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 16650 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 16651 | | if (_shouldTrace) |
| | 16652 | | { |
| 0 | 16653 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 16654 | | } |
| 0 | 16655 | | _httpRequest.Dispose(); |
| 0 | 16656 | | if (_httpResponse != null) |
| | 16657 | | { |
| 0 | 16658 | | _httpResponse.Dispose(); |
| | 16659 | | } |
| 0 | 16660 | | throw ex; |
| | 16661 | | } |
| | 16662 | | // Create Result |
| 0 | 16663 | | var _result = new HttpOperationResponse<EntityRole>(); |
| 0 | 16664 | | _result.Request = _httpRequest; |
| 0 | 16665 | | _result.Response = _httpResponse; |
| | 16666 | | // Deserialize Response |
| 0 | 16667 | | if ((int)_statusCode == 200) |
| | 16668 | | { |
| 0 | 16669 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 16670 | | try |
| | 16671 | | { |
| 0 | 16672 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl |
| 0 | 16673 | | } |
| 0 | 16674 | | catch (JsonException ex) |
| | 16675 | | { |
| 0 | 16676 | | _httpRequest.Dispose(); |
| 0 | 16677 | | if (_httpResponse != null) |
| | 16678 | | { |
| 0 | 16679 | | _httpResponse.Dispose(); |
| | 16680 | | } |
| 0 | 16681 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 16682 | | } |
| | 16683 | | } |
| 0 | 16684 | | if (_shouldTrace) |
| | 16685 | | { |
| 0 | 16686 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 16687 | | } |
| 0 | 16688 | | return _result; |
| 0 | 16689 | | } |
| | 16690 | |
|
| | 16691 | | /// <summary> |
| | 16692 | | /// Update a role for a given composite entity in a version of the application |
| | 16693 | | /// </summary> |
| | 16694 | | /// <param name='appId'> |
| | 16695 | | /// The application ID. |
| | 16696 | | /// </param> |
| | 16697 | | /// <param name='versionId'> |
| | 16698 | | /// The version ID. |
| | 16699 | | /// </param> |
| | 16700 | | /// <param name='cEntityId'> |
| | 16701 | | /// The composite entity extractor ID. |
| | 16702 | | /// </param> |
| | 16703 | | /// <param name='roleId'> |
| | 16704 | | /// The entity role ID. |
| | 16705 | | /// </param> |
| | 16706 | | /// <param name='entityRoleUpdateObject'> |
| | 16707 | | /// The new entity role. |
| | 16708 | | /// </param> |
| | 16709 | | /// <param name='customHeaders'> |
| | 16710 | | /// Headers that will be added to request. |
| | 16711 | | /// </param> |
| | 16712 | | /// <param name='cancellationToken'> |
| | 16713 | | /// The cancellation token. |
| | 16714 | | /// </param> |
| | 16715 | | /// <exception cref="ErrorResponseException"> |
| | 16716 | | /// Thrown when the operation returned an invalid status code |
| | 16717 | | /// </exception> |
| | 16718 | | /// <exception cref="SerializationException"> |
| | 16719 | | /// Thrown when unable to deserialize the response |
| | 16720 | | /// </exception> |
| | 16721 | | /// <exception cref="ValidationException"> |
| | 16722 | | /// Thrown when a required parameter is null |
| | 16723 | | /// </exception> |
| | 16724 | | /// <exception cref="System.ArgumentNullException"> |
| | 16725 | | /// Thrown when a required parameter is null |
| | 16726 | | /// </exception> |
| | 16727 | | /// <return> |
| | 16728 | | /// A response object containing the response body and response headers. |
| | 16729 | | /// </return> |
| | 16730 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateCompositeEntityRoleWithHttpMessagesAsync(System. |
| | 16731 | | { |
| 0 | 16732 | | if (Client.Endpoint == null) |
| | 16733 | | { |
| 0 | 16734 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 16735 | | } |
| 0 | 16736 | | if (versionId == null) |
| | 16737 | | { |
| 0 | 16738 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 16739 | | } |
| 0 | 16740 | | if (entityRoleUpdateObject == null) |
| | 16741 | | { |
| 0 | 16742 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject"); |
| | 16743 | | } |
| | 16744 | | // Tracing |
| 0 | 16745 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 16746 | | string _invocationId = null; |
| 0 | 16747 | | if (_shouldTrace) |
| | 16748 | | { |
| 0 | 16749 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 16750 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 16751 | | tracingParameters.Add("appId", appId); |
| 0 | 16752 | | tracingParameters.Add("versionId", versionId); |
| 0 | 16753 | | tracingParameters.Add("cEntityId", cEntityId); |
| 0 | 16754 | | tracingParameters.Add("roleId", roleId); |
| 0 | 16755 | | tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject); |
| 0 | 16756 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 16757 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateCompositeEntityRole", tracingParameters); |
| | 16758 | | } |
| | 16759 | | // Construct URL |
| 0 | 16760 | | var _baseUrl = Client.BaseUri; |
| 0 | 16761 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti |
| 0 | 16762 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 16763 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 16764 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 16765 | | _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| 0 | 16766 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 16767 | | // Create HTTP transport objects |
| 0 | 16768 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 16769 | | HttpResponseMessage _httpResponse = null; |
| 0 | 16770 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 0 | 16771 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 16772 | | // Set Headers |
| | 16773 | |
|
| | 16774 | |
|
| 0 | 16775 | | if (customHeaders != null) |
| | 16776 | | { |
| 0 | 16777 | | foreach(var _header in customHeaders) |
| | 16778 | | { |
| 0 | 16779 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 16780 | | { |
| 0 | 16781 | | _httpRequest.Headers.Remove(_header.Key); |
| | 16782 | | } |
| 0 | 16783 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 16784 | | } |
| | 16785 | | } |
| | 16786 | |
|
| | 16787 | | // Serialize Request |
| 0 | 16788 | | string _requestContent = null; |
| 0 | 16789 | | if(entityRoleUpdateObject != null) |
| | 16790 | | { |
| 0 | 16791 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri |
| 0 | 16792 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 16793 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 16794 | | } |
| | 16795 | | // Set Credentials |
| 0 | 16796 | | if (Client.Credentials != null) |
| | 16797 | | { |
| 0 | 16798 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 16799 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 16800 | | } |
| | 16801 | | // Send Request |
| 0 | 16802 | | if (_shouldTrace) |
| | 16803 | | { |
| 0 | 16804 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 16805 | | } |
| 0 | 16806 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 16807 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 16808 | | if (_shouldTrace) |
| | 16809 | | { |
| 0 | 16810 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 16811 | | } |
| 0 | 16812 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 16813 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 16814 | | string _responseContent = null; |
| 0 | 16815 | | if ((int)_statusCode != 200) |
| | 16816 | | { |
| 0 | 16817 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 16818 | | try |
| | 16819 | | { |
| 0 | 16820 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 16821 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 16822 | | if (_errorBody != null) |
| | 16823 | | { |
| 0 | 16824 | | ex.Body = _errorBody; |
| | 16825 | | } |
| 0 | 16826 | | } |
| 0 | 16827 | | catch (JsonException) |
| | 16828 | | { |
| | 16829 | | // Ignore the exception |
| 0 | 16830 | | } |
| 0 | 16831 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 16832 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 16833 | | if (_shouldTrace) |
| | 16834 | | { |
| 0 | 16835 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 16836 | | } |
| 0 | 16837 | | _httpRequest.Dispose(); |
| 0 | 16838 | | if (_httpResponse != null) |
| | 16839 | | { |
| 0 | 16840 | | _httpResponse.Dispose(); |
| | 16841 | | } |
| 0 | 16842 | | throw ex; |
| | 16843 | | } |
| | 16844 | | // Create Result |
| 0 | 16845 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 0 | 16846 | | _result.Request = _httpRequest; |
| 0 | 16847 | | _result.Response = _httpResponse; |
| | 16848 | | // Deserialize Response |
| 0 | 16849 | | if ((int)_statusCode == 200) |
| | 16850 | | { |
| 0 | 16851 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 16852 | | try |
| | 16853 | | { |
| 0 | 16854 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 0 | 16855 | | } |
| 0 | 16856 | | catch (JsonException ex) |
| | 16857 | | { |
| 0 | 16858 | | _httpRequest.Dispose(); |
| 0 | 16859 | | if (_httpResponse != null) |
| | 16860 | | { |
| 0 | 16861 | | _httpResponse.Dispose(); |
| | 16862 | | } |
| 0 | 16863 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 16864 | | } |
| | 16865 | | } |
| 0 | 16866 | | if (_shouldTrace) |
| | 16867 | | { |
| 0 | 16868 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 16869 | | } |
| 0 | 16870 | | return _result; |
| 0 | 16871 | | } |
| | 16872 | |
|
| | 16873 | | /// <summary> |
| | 16874 | | /// Delete a role for a given composite entity in a version of the application. |
| | 16875 | | /// </summary> |
| | 16876 | | /// <param name='appId'> |
| | 16877 | | /// The application ID. |
| | 16878 | | /// </param> |
| | 16879 | | /// <param name='versionId'> |
| | 16880 | | /// The version ID. |
| | 16881 | | /// </param> |
| | 16882 | | /// <param name='cEntityId'> |
| | 16883 | | /// The composite entity extractor ID. |
| | 16884 | | /// </param> |
| | 16885 | | /// <param name='roleId'> |
| | 16886 | | /// The entity role Id. |
| | 16887 | | /// </param> |
| | 16888 | | /// <param name='customHeaders'> |
| | 16889 | | /// Headers that will be added to request. |
| | 16890 | | /// </param> |
| | 16891 | | /// <param name='cancellationToken'> |
| | 16892 | | /// The cancellation token. |
| | 16893 | | /// </param> |
| | 16894 | | /// <exception cref="ErrorResponseException"> |
| | 16895 | | /// Thrown when the operation returned an invalid status code |
| | 16896 | | /// </exception> |
| | 16897 | | /// <exception cref="SerializationException"> |
| | 16898 | | /// Thrown when unable to deserialize the response |
| | 16899 | | /// </exception> |
| | 16900 | | /// <exception cref="ValidationException"> |
| | 16901 | | /// Thrown when a required parameter is null |
| | 16902 | | /// </exception> |
| | 16903 | | /// <exception cref="System.ArgumentNullException"> |
| | 16904 | | /// Thrown when a required parameter is null |
| | 16905 | | /// </exception> |
| | 16906 | | /// <return> |
| | 16907 | | /// A response object containing the response body and response headers. |
| | 16908 | | /// </return> |
| | 16909 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteCompositeEntityRoleWithHttpMessagesAsync(System. |
| | 16910 | | { |
| 0 | 16911 | | if (Client.Endpoint == null) |
| | 16912 | | { |
| 0 | 16913 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 16914 | | } |
| 0 | 16915 | | if (versionId == null) |
| | 16916 | | { |
| 0 | 16917 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 16918 | | } |
| | 16919 | | // Tracing |
| 0 | 16920 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 16921 | | string _invocationId = null; |
| 0 | 16922 | | if (_shouldTrace) |
| | 16923 | | { |
| 0 | 16924 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 16925 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 16926 | | tracingParameters.Add("appId", appId); |
| 0 | 16927 | | tracingParameters.Add("versionId", versionId); |
| 0 | 16928 | | tracingParameters.Add("cEntityId", cEntityId); |
| 0 | 16929 | | tracingParameters.Add("roleId", roleId); |
| 0 | 16930 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 16931 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteCompositeEntityRole", tracingParameters); |
| | 16932 | | } |
| | 16933 | | // Construct URL |
| 0 | 16934 | | var _baseUrl = Client.BaseUri; |
| 0 | 16935 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/compositeenti |
| 0 | 16936 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 16937 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 16938 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 16939 | | _url = _url.Replace("{cEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| 0 | 16940 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 16941 | | // Create HTTP transport objects |
| 0 | 16942 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 16943 | | HttpResponseMessage _httpResponse = null; |
| 0 | 16944 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 0 | 16945 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 16946 | | // Set Headers |
| | 16947 | |
|
| | 16948 | |
|
| 0 | 16949 | | if (customHeaders != null) |
| | 16950 | | { |
| 0 | 16951 | | foreach(var _header in customHeaders) |
| | 16952 | | { |
| 0 | 16953 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 16954 | | { |
| 0 | 16955 | | _httpRequest.Headers.Remove(_header.Key); |
| | 16956 | | } |
| 0 | 16957 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 16958 | | } |
| | 16959 | | } |
| | 16960 | |
|
| | 16961 | | // Serialize Request |
| 0 | 16962 | | string _requestContent = null; |
| | 16963 | | // Set Credentials |
| 0 | 16964 | | if (Client.Credentials != null) |
| | 16965 | | { |
| 0 | 16966 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 16967 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 16968 | | } |
| | 16969 | | // Send Request |
| 0 | 16970 | | if (_shouldTrace) |
| | 16971 | | { |
| 0 | 16972 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 16973 | | } |
| 0 | 16974 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 16975 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 16976 | | if (_shouldTrace) |
| | 16977 | | { |
| 0 | 16978 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 16979 | | } |
| 0 | 16980 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 16981 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 16982 | | string _responseContent = null; |
| 0 | 16983 | | if ((int)_statusCode != 200) |
| | 16984 | | { |
| 0 | 16985 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 16986 | | try |
| | 16987 | | { |
| 0 | 16988 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 16989 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 16990 | | if (_errorBody != null) |
| | 16991 | | { |
| 0 | 16992 | | ex.Body = _errorBody; |
| | 16993 | | } |
| 0 | 16994 | | } |
| 0 | 16995 | | catch (JsonException) |
| | 16996 | | { |
| | 16997 | | // Ignore the exception |
| 0 | 16998 | | } |
| 0 | 16999 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 17000 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 17001 | | if (_shouldTrace) |
| | 17002 | | { |
| 0 | 17003 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 17004 | | } |
| 0 | 17005 | | _httpRequest.Dispose(); |
| 0 | 17006 | | if (_httpResponse != null) |
| | 17007 | | { |
| 0 | 17008 | | _httpResponse.Dispose(); |
| | 17009 | | } |
| 0 | 17010 | | throw ex; |
| | 17011 | | } |
| | 17012 | | // Create Result |
| 0 | 17013 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 0 | 17014 | | _result.Request = _httpRequest; |
| 0 | 17015 | | _result.Response = _httpResponse; |
| | 17016 | | // Deserialize Response |
| 0 | 17017 | | if ((int)_statusCode == 200) |
| | 17018 | | { |
| 0 | 17019 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 17020 | | try |
| | 17021 | | { |
| 0 | 17022 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 0 | 17023 | | } |
| 0 | 17024 | | catch (JsonException ex) |
| | 17025 | | { |
| 0 | 17026 | | _httpRequest.Dispose(); |
| 0 | 17027 | | if (_httpResponse != null) |
| | 17028 | | { |
| 0 | 17029 | | _httpResponse.Dispose(); |
| | 17030 | | } |
| 0 | 17031 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 17032 | | } |
| | 17033 | | } |
| 0 | 17034 | | if (_shouldTrace) |
| | 17035 | | { |
| 0 | 17036 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 17037 | | } |
| 0 | 17038 | | return _result; |
| 0 | 17039 | | } |
| | 17040 | |
|
| | 17041 | | /// <summary> |
| | 17042 | | /// Get one role for a given Pattern.any entity in a version of the |
| | 17043 | | /// application. |
| | 17044 | | /// </summary> |
| | 17045 | | /// <param name='appId'> |
| | 17046 | | /// The application ID. |
| | 17047 | | /// </param> |
| | 17048 | | /// <param name='versionId'> |
| | 17049 | | /// The version ID. |
| | 17050 | | /// </param> |
| | 17051 | | /// <param name='entityId'> |
| | 17052 | | /// entity ID. |
| | 17053 | | /// </param> |
| | 17054 | | /// <param name='roleId'> |
| | 17055 | | /// entity role ID. |
| | 17056 | | /// </param> |
| | 17057 | | /// <param name='customHeaders'> |
| | 17058 | | /// Headers that will be added to request. |
| | 17059 | | /// </param> |
| | 17060 | | /// <param name='cancellationToken'> |
| | 17061 | | /// The cancellation token. |
| | 17062 | | /// </param> |
| | 17063 | | /// <exception cref="ErrorResponseException"> |
| | 17064 | | /// Thrown when the operation returned an invalid status code |
| | 17065 | | /// </exception> |
| | 17066 | | /// <exception cref="SerializationException"> |
| | 17067 | | /// Thrown when unable to deserialize the response |
| | 17068 | | /// </exception> |
| | 17069 | | /// <exception cref="ValidationException"> |
| | 17070 | | /// Thrown when a required parameter is null |
| | 17071 | | /// </exception> |
| | 17072 | | /// <exception cref="System.ArgumentNullException"> |
| | 17073 | | /// Thrown when a required parameter is null |
| | 17074 | | /// </exception> |
| | 17075 | | /// <return> |
| | 17076 | | /// A response object containing the response body and response headers. |
| | 17077 | | /// </return> |
| | 17078 | | public async Task<HttpOperationResponse<EntityRole>> GetPatternAnyEntityRoleWithHttpMessagesAsync(System.Guid ap |
| | 17079 | | { |
| 2 | 17080 | | if (Client.Endpoint == null) |
| | 17081 | | { |
| 0 | 17082 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 17083 | | } |
| 2 | 17084 | | if (versionId == null) |
| | 17085 | | { |
| 0 | 17086 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 17087 | | } |
| | 17088 | | // Tracing |
| 2 | 17089 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 17090 | | string _invocationId = null; |
| 2 | 17091 | | if (_shouldTrace) |
| | 17092 | | { |
| 0 | 17093 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 17094 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 17095 | | tracingParameters.Add("appId", appId); |
| 0 | 17096 | | tracingParameters.Add("versionId", versionId); |
| 0 | 17097 | | tracingParameters.Add("entityId", entityId); |
| 0 | 17098 | | tracingParameters.Add("roleId", roleId); |
| 0 | 17099 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 17100 | | ServiceClientTracing.Enter(_invocationId, this, "GetPatternAnyEntityRole", tracingParameters); |
| | 17101 | | } |
| | 17102 | | // Construct URL |
| 2 | 17103 | | var _baseUrl = Client.BaseUri; |
| 2 | 17104 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 2 | 17105 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 17106 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 17107 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 2 | 17108 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 2 | 17109 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 17110 | | // Create HTTP transport objects |
| 2 | 17111 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 17112 | | HttpResponseMessage _httpResponse = null; |
| 2 | 17113 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 17114 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 17115 | | // Set Headers |
| | 17116 | |
|
| | 17117 | |
|
| 2 | 17118 | | if (customHeaders != null) |
| | 17119 | | { |
| 0 | 17120 | | foreach(var _header in customHeaders) |
| | 17121 | | { |
| 0 | 17122 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 17123 | | { |
| 0 | 17124 | | _httpRequest.Headers.Remove(_header.Key); |
| | 17125 | | } |
| 0 | 17126 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 17127 | | } |
| | 17128 | | } |
| | 17129 | |
|
| | 17130 | | // Serialize Request |
| 2 | 17131 | | string _requestContent = null; |
| | 17132 | | // Set Credentials |
| 2 | 17133 | | if (Client.Credentials != null) |
| | 17134 | | { |
| 2 | 17135 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 17136 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 17137 | | } |
| | 17138 | | // Send Request |
| 2 | 17139 | | if (_shouldTrace) |
| | 17140 | | { |
| 0 | 17141 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 17142 | | } |
| 2 | 17143 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 17144 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 17145 | | if (_shouldTrace) |
| | 17146 | | { |
| 0 | 17147 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 17148 | | } |
| 2 | 17149 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 17150 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 17151 | | string _responseContent = null; |
| 2 | 17152 | | if ((int)_statusCode != 200) |
| | 17153 | | { |
| 0 | 17154 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 17155 | | try |
| | 17156 | | { |
| 0 | 17157 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 17158 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 17159 | | if (_errorBody != null) |
| | 17160 | | { |
| 0 | 17161 | | ex.Body = _errorBody; |
| | 17162 | | } |
| 0 | 17163 | | } |
| 0 | 17164 | | catch (JsonException) |
| | 17165 | | { |
| | 17166 | | // Ignore the exception |
| 0 | 17167 | | } |
| 0 | 17168 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 17169 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 17170 | | if (_shouldTrace) |
| | 17171 | | { |
| 0 | 17172 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 17173 | | } |
| 0 | 17174 | | _httpRequest.Dispose(); |
| 0 | 17175 | | if (_httpResponse != null) |
| | 17176 | | { |
| 0 | 17177 | | _httpResponse.Dispose(); |
| | 17178 | | } |
| 0 | 17179 | | throw ex; |
| | 17180 | | } |
| | 17181 | | // Create Result |
| 2 | 17182 | | var _result = new HttpOperationResponse<EntityRole>(); |
| 2 | 17183 | | _result.Request = _httpRequest; |
| 2 | 17184 | | _result.Response = _httpResponse; |
| | 17185 | | // Deserialize Response |
| 2 | 17186 | | if ((int)_statusCode == 200) |
| | 17187 | | { |
| 2 | 17188 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 17189 | | try |
| | 17190 | | { |
| 2 | 17191 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl |
| 2 | 17192 | | } |
| 0 | 17193 | | catch (JsonException ex) |
| | 17194 | | { |
| 0 | 17195 | | _httpRequest.Dispose(); |
| 0 | 17196 | | if (_httpResponse != null) |
| | 17197 | | { |
| 0 | 17198 | | _httpResponse.Dispose(); |
| | 17199 | | } |
| 0 | 17200 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 17201 | | } |
| | 17202 | | } |
| 2 | 17203 | | if (_shouldTrace) |
| | 17204 | | { |
| 0 | 17205 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 17206 | | } |
| 2 | 17207 | | return _result; |
| 2 | 17208 | | } |
| | 17209 | |
|
| | 17210 | | /// <summary> |
| | 17211 | | /// Update a role for a given Pattern.any entity in a version of the |
| | 17212 | | /// application. |
| | 17213 | | /// </summary> |
| | 17214 | | /// <param name='appId'> |
| | 17215 | | /// The application ID. |
| | 17216 | | /// </param> |
| | 17217 | | /// <param name='versionId'> |
| | 17218 | | /// The version ID. |
| | 17219 | | /// </param> |
| | 17220 | | /// <param name='entityId'> |
| | 17221 | | /// The entity ID. |
| | 17222 | | /// </param> |
| | 17223 | | /// <param name='roleId'> |
| | 17224 | | /// The entity role ID. |
| | 17225 | | /// </param> |
| | 17226 | | /// <param name='entityRoleUpdateObject'> |
| | 17227 | | /// The new entity role. |
| | 17228 | | /// </param> |
| | 17229 | | /// <param name='customHeaders'> |
| | 17230 | | /// Headers that will be added to request. |
| | 17231 | | /// </param> |
| | 17232 | | /// <param name='cancellationToken'> |
| | 17233 | | /// The cancellation token. |
| | 17234 | | /// </param> |
| | 17235 | | /// <exception cref="ErrorResponseException"> |
| | 17236 | | /// Thrown when the operation returned an invalid status code |
| | 17237 | | /// </exception> |
| | 17238 | | /// <exception cref="SerializationException"> |
| | 17239 | | /// Thrown when unable to deserialize the response |
| | 17240 | | /// </exception> |
| | 17241 | | /// <exception cref="ValidationException"> |
| | 17242 | | /// Thrown when a required parameter is null |
| | 17243 | | /// </exception> |
| | 17244 | | /// <exception cref="System.ArgumentNullException"> |
| | 17245 | | /// Thrown when a required parameter is null |
| | 17246 | | /// </exception> |
| | 17247 | | /// <return> |
| | 17248 | | /// A response object containing the response body and response headers. |
| | 17249 | | /// </return> |
| | 17250 | | public async Task<HttpOperationResponse<OperationStatus>> UpdatePatternAnyEntityRoleWithHttpMessagesAsync(System |
| | 17251 | | { |
| 1 | 17252 | | if (Client.Endpoint == null) |
| | 17253 | | { |
| 0 | 17254 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 17255 | | } |
| 1 | 17256 | | if (versionId == null) |
| | 17257 | | { |
| 0 | 17258 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 17259 | | } |
| 1 | 17260 | | if (entityRoleUpdateObject == null) |
| | 17261 | | { |
| 0 | 17262 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject"); |
| | 17263 | | } |
| | 17264 | | // Tracing |
| 1 | 17265 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 17266 | | string _invocationId = null; |
| 1 | 17267 | | if (_shouldTrace) |
| | 17268 | | { |
| 0 | 17269 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 17270 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 17271 | | tracingParameters.Add("appId", appId); |
| 0 | 17272 | | tracingParameters.Add("versionId", versionId); |
| 0 | 17273 | | tracingParameters.Add("entityId", entityId); |
| 0 | 17274 | | tracingParameters.Add("roleId", roleId); |
| 0 | 17275 | | tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject); |
| 0 | 17276 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 17277 | | ServiceClientTracing.Enter(_invocationId, this, "UpdatePatternAnyEntityRole", tracingParameters); |
| | 17278 | | } |
| | 17279 | | // Construct URL |
| 1 | 17280 | | var _baseUrl = Client.BaseUri; |
| 1 | 17281 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 1 | 17282 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 17283 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 17284 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 17285 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 17286 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 17287 | | // Create HTTP transport objects |
| 1 | 17288 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 17289 | | HttpResponseMessage _httpResponse = null; |
| 1 | 17290 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 1 | 17291 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 17292 | | // Set Headers |
| | 17293 | |
|
| | 17294 | |
|
| 1 | 17295 | | if (customHeaders != null) |
| | 17296 | | { |
| 0 | 17297 | | foreach(var _header in customHeaders) |
| | 17298 | | { |
| 0 | 17299 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 17300 | | { |
| 0 | 17301 | | _httpRequest.Headers.Remove(_header.Key); |
| | 17302 | | } |
| 0 | 17303 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 17304 | | } |
| | 17305 | | } |
| | 17306 | |
|
| | 17307 | | // Serialize Request |
| 1 | 17308 | | string _requestContent = null; |
| 1 | 17309 | | if(entityRoleUpdateObject != null) |
| | 17310 | | { |
| 1 | 17311 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri |
| 1 | 17312 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 17313 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 17314 | | } |
| | 17315 | | // Set Credentials |
| 1 | 17316 | | if (Client.Credentials != null) |
| | 17317 | | { |
| 1 | 17318 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 17319 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 17320 | | } |
| | 17321 | | // Send Request |
| 1 | 17322 | | if (_shouldTrace) |
| | 17323 | | { |
| 0 | 17324 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 17325 | | } |
| 1 | 17326 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 17327 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 17328 | | if (_shouldTrace) |
| | 17329 | | { |
| 0 | 17330 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 17331 | | } |
| 1 | 17332 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 17333 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 17334 | | string _responseContent = null; |
| 1 | 17335 | | if ((int)_statusCode != 200) |
| | 17336 | | { |
| 0 | 17337 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 17338 | | try |
| | 17339 | | { |
| 0 | 17340 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 17341 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 17342 | | if (_errorBody != null) |
| | 17343 | | { |
| 0 | 17344 | | ex.Body = _errorBody; |
| | 17345 | | } |
| 0 | 17346 | | } |
| 0 | 17347 | | catch (JsonException) |
| | 17348 | | { |
| | 17349 | | // Ignore the exception |
| 0 | 17350 | | } |
| 0 | 17351 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 17352 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 17353 | | if (_shouldTrace) |
| | 17354 | | { |
| 0 | 17355 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 17356 | | } |
| 0 | 17357 | | _httpRequest.Dispose(); |
| 0 | 17358 | | if (_httpResponse != null) |
| | 17359 | | { |
| 0 | 17360 | | _httpResponse.Dispose(); |
| | 17361 | | } |
| 0 | 17362 | | throw ex; |
| | 17363 | | } |
| | 17364 | | // Create Result |
| 1 | 17365 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 17366 | | _result.Request = _httpRequest; |
| 1 | 17367 | | _result.Response = _httpResponse; |
| | 17368 | | // Deserialize Response |
| 1 | 17369 | | if ((int)_statusCode == 200) |
| | 17370 | | { |
| 1 | 17371 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 17372 | | try |
| | 17373 | | { |
| 1 | 17374 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 17375 | | } |
| 0 | 17376 | | catch (JsonException ex) |
| | 17377 | | { |
| 0 | 17378 | | _httpRequest.Dispose(); |
| 0 | 17379 | | if (_httpResponse != null) |
| | 17380 | | { |
| 0 | 17381 | | _httpResponse.Dispose(); |
| | 17382 | | } |
| 0 | 17383 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 17384 | | } |
| | 17385 | | } |
| 1 | 17386 | | if (_shouldTrace) |
| | 17387 | | { |
| 0 | 17388 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 17389 | | } |
| 1 | 17390 | | return _result; |
| 1 | 17391 | | } |
| | 17392 | |
|
| | 17393 | | /// <summary> |
| | 17394 | | /// Delete a role for a given Pattern.any entity in a version of the |
| | 17395 | | /// application. |
| | 17396 | | /// </summary> |
| | 17397 | | /// <param name='appId'> |
| | 17398 | | /// The application ID. |
| | 17399 | | /// </param> |
| | 17400 | | /// <param name='versionId'> |
| | 17401 | | /// The version ID. |
| | 17402 | | /// </param> |
| | 17403 | | /// <param name='entityId'> |
| | 17404 | | /// The entity ID. |
| | 17405 | | /// </param> |
| | 17406 | | /// <param name='roleId'> |
| | 17407 | | /// The entity role Id. |
| | 17408 | | /// </param> |
| | 17409 | | /// <param name='customHeaders'> |
| | 17410 | | /// Headers that will be added to request. |
| | 17411 | | /// </param> |
| | 17412 | | /// <param name='cancellationToken'> |
| | 17413 | | /// The cancellation token. |
| | 17414 | | /// </param> |
| | 17415 | | /// <exception cref="ErrorResponseException"> |
| | 17416 | | /// Thrown when the operation returned an invalid status code |
| | 17417 | | /// </exception> |
| | 17418 | | /// <exception cref="SerializationException"> |
| | 17419 | | /// Thrown when unable to deserialize the response |
| | 17420 | | /// </exception> |
| | 17421 | | /// <exception cref="ValidationException"> |
| | 17422 | | /// Thrown when a required parameter is null |
| | 17423 | | /// </exception> |
| | 17424 | | /// <exception cref="System.ArgumentNullException"> |
| | 17425 | | /// Thrown when a required parameter is null |
| | 17426 | | /// </exception> |
| | 17427 | | /// <return> |
| | 17428 | | /// A response object containing the response body and response headers. |
| | 17429 | | /// </return> |
| | 17430 | | public async Task<HttpOperationResponse<OperationStatus>> DeletePatternAnyEntityRoleWithHttpMessagesAsync(System |
| | 17431 | | { |
| 1 | 17432 | | if (Client.Endpoint == null) |
| | 17433 | | { |
| 0 | 17434 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 17435 | | } |
| 1 | 17436 | | if (versionId == null) |
| | 17437 | | { |
| 0 | 17438 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 17439 | | } |
| | 17440 | | // Tracing |
| 1 | 17441 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 17442 | | string _invocationId = null; |
| 1 | 17443 | | if (_shouldTrace) |
| | 17444 | | { |
| 0 | 17445 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 17446 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 17447 | | tracingParameters.Add("appId", appId); |
| 0 | 17448 | | tracingParameters.Add("versionId", versionId); |
| 0 | 17449 | | tracingParameters.Add("entityId", entityId); |
| 0 | 17450 | | tracingParameters.Add("roleId", roleId); |
| 0 | 17451 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 17452 | | ServiceClientTracing.Enter(_invocationId, this, "DeletePatternAnyEntityRole", tracingParameters); |
| | 17453 | | } |
| | 17454 | | // Construct URL |
| 1 | 17455 | | var _baseUrl = Client.BaseUri; |
| 1 | 17456 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 1 | 17457 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 17458 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 17459 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 17460 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 17461 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 17462 | | // Create HTTP transport objects |
| 1 | 17463 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 17464 | | HttpResponseMessage _httpResponse = null; |
| 1 | 17465 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 1 | 17466 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 17467 | | // Set Headers |
| | 17468 | |
|
| | 17469 | |
|
| 1 | 17470 | | if (customHeaders != null) |
| | 17471 | | { |
| 0 | 17472 | | foreach(var _header in customHeaders) |
| | 17473 | | { |
| 0 | 17474 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 17475 | | { |
| 0 | 17476 | | _httpRequest.Headers.Remove(_header.Key); |
| | 17477 | | } |
| 0 | 17478 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 17479 | | } |
| | 17480 | | } |
| | 17481 | |
|
| | 17482 | | // Serialize Request |
| 1 | 17483 | | string _requestContent = null; |
| | 17484 | | // Set Credentials |
| 1 | 17485 | | if (Client.Credentials != null) |
| | 17486 | | { |
| 1 | 17487 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 17488 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 17489 | | } |
| | 17490 | | // Send Request |
| 1 | 17491 | | if (_shouldTrace) |
| | 17492 | | { |
| 0 | 17493 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 17494 | | } |
| 1 | 17495 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 17496 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 17497 | | if (_shouldTrace) |
| | 17498 | | { |
| 0 | 17499 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 17500 | | } |
| 1 | 17501 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 17502 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 17503 | | string _responseContent = null; |
| 1 | 17504 | | if ((int)_statusCode != 200) |
| | 17505 | | { |
| 0 | 17506 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 17507 | | try |
| | 17508 | | { |
| 0 | 17509 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 17510 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 17511 | | if (_errorBody != null) |
| | 17512 | | { |
| 0 | 17513 | | ex.Body = _errorBody; |
| | 17514 | | } |
| 0 | 17515 | | } |
| 0 | 17516 | | catch (JsonException) |
| | 17517 | | { |
| | 17518 | | // Ignore the exception |
| 0 | 17519 | | } |
| 0 | 17520 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 17521 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 17522 | | if (_shouldTrace) |
| | 17523 | | { |
| 0 | 17524 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 17525 | | } |
| 0 | 17526 | | _httpRequest.Dispose(); |
| 0 | 17527 | | if (_httpResponse != null) |
| | 17528 | | { |
| 0 | 17529 | | _httpResponse.Dispose(); |
| | 17530 | | } |
| 0 | 17531 | | throw ex; |
| | 17532 | | } |
| | 17533 | | // Create Result |
| 1 | 17534 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 17535 | | _result.Request = _httpRequest; |
| 1 | 17536 | | _result.Response = _httpResponse; |
| | 17537 | | // Deserialize Response |
| 1 | 17538 | | if ((int)_statusCode == 200) |
| | 17539 | | { |
| 1 | 17540 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 17541 | | try |
| | 17542 | | { |
| 1 | 17543 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 17544 | | } |
| 0 | 17545 | | catch (JsonException ex) |
| | 17546 | | { |
| 0 | 17547 | | _httpRequest.Dispose(); |
| 0 | 17548 | | if (_httpResponse != null) |
| | 17549 | | { |
| 0 | 17550 | | _httpResponse.Dispose(); |
| | 17551 | | } |
| 0 | 17552 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 17553 | | } |
| | 17554 | | } |
| 1 | 17555 | | if (_shouldTrace) |
| | 17556 | | { |
| 0 | 17557 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 17558 | | } |
| 1 | 17559 | | return _result; |
| 1 | 17560 | | } |
| | 17561 | |
|
| | 17562 | | /// <summary> |
| | 17563 | | /// Get one role for a given hierarchical entity in a version of the |
| | 17564 | | /// application. |
| | 17565 | | /// </summary> |
| | 17566 | | /// <param name='appId'> |
| | 17567 | | /// The application ID. |
| | 17568 | | /// </param> |
| | 17569 | | /// <param name='versionId'> |
| | 17570 | | /// The version ID. |
| | 17571 | | /// </param> |
| | 17572 | | /// <param name='hEntityId'> |
| | 17573 | | /// The hierarchical entity extractor ID. |
| | 17574 | | /// </param> |
| | 17575 | | /// <param name='roleId'> |
| | 17576 | | /// entity role ID. |
| | 17577 | | /// </param> |
| | 17578 | | /// <param name='customHeaders'> |
| | 17579 | | /// Headers that will be added to request. |
| | 17580 | | /// </param> |
| | 17581 | | /// <param name='cancellationToken'> |
| | 17582 | | /// The cancellation token. |
| | 17583 | | /// </param> |
| | 17584 | | /// <exception cref="ErrorResponseException"> |
| | 17585 | | /// Thrown when the operation returned an invalid status code |
| | 17586 | | /// </exception> |
| | 17587 | | /// <exception cref="SerializationException"> |
| | 17588 | | /// Thrown when unable to deserialize the response |
| | 17589 | | /// </exception> |
| | 17590 | | /// <exception cref="ValidationException"> |
| | 17591 | | /// Thrown when a required parameter is null |
| | 17592 | | /// </exception> |
| | 17593 | | /// <exception cref="System.ArgumentNullException"> |
| | 17594 | | /// Thrown when a required parameter is null |
| | 17595 | | /// </exception> |
| | 17596 | | /// <return> |
| | 17597 | | /// A response object containing the response body and response headers. |
| | 17598 | | /// </return> |
| | 17599 | | public async Task<HttpOperationResponse<EntityRole>> GetHierarchicalEntityRoleWithHttpMessagesAsync(System.Guid |
| | 17600 | | { |
| 0 | 17601 | | if (Client.Endpoint == null) |
| | 17602 | | { |
| 0 | 17603 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 17604 | | } |
| 0 | 17605 | | if (versionId == null) |
| | 17606 | | { |
| 0 | 17607 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 17608 | | } |
| | 17609 | | // Tracing |
| 0 | 17610 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 17611 | | string _invocationId = null; |
| 0 | 17612 | | if (_shouldTrace) |
| | 17613 | | { |
| 0 | 17614 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 17615 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 17616 | | tracingParameters.Add("appId", appId); |
| 0 | 17617 | | tracingParameters.Add("versionId", versionId); |
| 0 | 17618 | | tracingParameters.Add("hEntityId", hEntityId); |
| 0 | 17619 | | tracingParameters.Add("roleId", roleId); |
| 0 | 17620 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 17621 | | ServiceClientTracing.Enter(_invocationId, this, "GetHierarchicalEntityRole", tracingParameters); |
| | 17622 | | } |
| | 17623 | | // Construct URL |
| 0 | 17624 | | var _baseUrl = Client.BaseUri; |
| 0 | 17625 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale |
| 0 | 17626 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 17627 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 17628 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 17629 | | _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| 0 | 17630 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 17631 | | // Create HTTP transport objects |
| 0 | 17632 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 17633 | | HttpResponseMessage _httpResponse = null; |
| 0 | 17634 | | _httpRequest.Method = new HttpMethod("GET"); |
| 0 | 17635 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 17636 | | // Set Headers |
| | 17637 | |
|
| | 17638 | |
|
| 0 | 17639 | | if (customHeaders != null) |
| | 17640 | | { |
| 0 | 17641 | | foreach(var _header in customHeaders) |
| | 17642 | | { |
| 0 | 17643 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 17644 | | { |
| 0 | 17645 | | _httpRequest.Headers.Remove(_header.Key); |
| | 17646 | | } |
| 0 | 17647 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 17648 | | } |
| | 17649 | | } |
| | 17650 | |
|
| | 17651 | | // Serialize Request |
| 0 | 17652 | | string _requestContent = null; |
| | 17653 | | // Set Credentials |
| 0 | 17654 | | if (Client.Credentials != null) |
| | 17655 | | { |
| 0 | 17656 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 17657 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 17658 | | } |
| | 17659 | | // Send Request |
| 0 | 17660 | | if (_shouldTrace) |
| | 17661 | | { |
| 0 | 17662 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 17663 | | } |
| 0 | 17664 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 17665 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 17666 | | if (_shouldTrace) |
| | 17667 | | { |
| 0 | 17668 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 17669 | | } |
| 0 | 17670 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 17671 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 17672 | | string _responseContent = null; |
| 0 | 17673 | | if ((int)_statusCode != 200) |
| | 17674 | | { |
| 0 | 17675 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 17676 | | try |
| | 17677 | | { |
| 0 | 17678 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 17679 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 17680 | | if (_errorBody != null) |
| | 17681 | | { |
| 0 | 17682 | | ex.Body = _errorBody; |
| | 17683 | | } |
| 0 | 17684 | | } |
| 0 | 17685 | | catch (JsonException) |
| | 17686 | | { |
| | 17687 | | // Ignore the exception |
| 0 | 17688 | | } |
| 0 | 17689 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 17690 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 17691 | | if (_shouldTrace) |
| | 17692 | | { |
| 0 | 17693 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 17694 | | } |
| 0 | 17695 | | _httpRequest.Dispose(); |
| 0 | 17696 | | if (_httpResponse != null) |
| | 17697 | | { |
| 0 | 17698 | | _httpResponse.Dispose(); |
| | 17699 | | } |
| 0 | 17700 | | throw ex; |
| | 17701 | | } |
| | 17702 | | // Create Result |
| 0 | 17703 | | var _result = new HttpOperationResponse<EntityRole>(); |
| 0 | 17704 | | _result.Request = _httpRequest; |
| 0 | 17705 | | _result.Response = _httpResponse; |
| | 17706 | | // Deserialize Response |
| 0 | 17707 | | if ((int)_statusCode == 200) |
| | 17708 | | { |
| 0 | 17709 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 17710 | | try |
| | 17711 | | { |
| 0 | 17712 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl |
| 0 | 17713 | | } |
| 0 | 17714 | | catch (JsonException ex) |
| | 17715 | | { |
| 0 | 17716 | | _httpRequest.Dispose(); |
| 0 | 17717 | | if (_httpResponse != null) |
| | 17718 | | { |
| 0 | 17719 | | _httpResponse.Dispose(); |
| | 17720 | | } |
| 0 | 17721 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 17722 | | } |
| | 17723 | | } |
| 0 | 17724 | | if (_shouldTrace) |
| | 17725 | | { |
| 0 | 17726 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 17727 | | } |
| 0 | 17728 | | return _result; |
| 0 | 17729 | | } |
| | 17730 | |
|
| | 17731 | | /// <summary> |
| | 17732 | | /// Update a role for a given hierarchical entity in a version of the |
| | 17733 | | /// application. |
| | 17734 | | /// </summary> |
| | 17735 | | /// <param name='appId'> |
| | 17736 | | /// The application ID. |
| | 17737 | | /// </param> |
| | 17738 | | /// <param name='versionId'> |
| | 17739 | | /// The version ID. |
| | 17740 | | /// </param> |
| | 17741 | | /// <param name='hEntityId'> |
| | 17742 | | /// The hierarchical entity extractor ID. |
| | 17743 | | /// </param> |
| | 17744 | | /// <param name='roleId'> |
| | 17745 | | /// The entity role ID. |
| | 17746 | | /// </param> |
| | 17747 | | /// <param name='entityRoleUpdateObject'> |
| | 17748 | | /// The new entity role. |
| | 17749 | | /// </param> |
| | 17750 | | /// <param name='customHeaders'> |
| | 17751 | | /// Headers that will be added to request. |
| | 17752 | | /// </param> |
| | 17753 | | /// <param name='cancellationToken'> |
| | 17754 | | /// The cancellation token. |
| | 17755 | | /// </param> |
| | 17756 | | /// <exception cref="ErrorResponseException"> |
| | 17757 | | /// Thrown when the operation returned an invalid status code |
| | 17758 | | /// </exception> |
| | 17759 | | /// <exception cref="SerializationException"> |
| | 17760 | | /// Thrown when unable to deserialize the response |
| | 17761 | | /// </exception> |
| | 17762 | | /// <exception cref="ValidationException"> |
| | 17763 | | /// Thrown when a required parameter is null |
| | 17764 | | /// </exception> |
| | 17765 | | /// <exception cref="System.ArgumentNullException"> |
| | 17766 | | /// Thrown when a required parameter is null |
| | 17767 | | /// </exception> |
| | 17768 | | /// <return> |
| | 17769 | | /// A response object containing the response body and response headers. |
| | 17770 | | /// </return> |
| | 17771 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateHierarchicalEntityRoleWithHttpMessagesAsync(Syst |
| | 17772 | | { |
| 0 | 17773 | | if (Client.Endpoint == null) |
| | 17774 | | { |
| 0 | 17775 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 17776 | | } |
| 0 | 17777 | | if (versionId == null) |
| | 17778 | | { |
| 0 | 17779 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 17780 | | } |
| 0 | 17781 | | if (entityRoleUpdateObject == null) |
| | 17782 | | { |
| 0 | 17783 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject"); |
| | 17784 | | } |
| | 17785 | | // Tracing |
| 0 | 17786 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 17787 | | string _invocationId = null; |
| 0 | 17788 | | if (_shouldTrace) |
| | 17789 | | { |
| 0 | 17790 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 17791 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 17792 | | tracingParameters.Add("appId", appId); |
| 0 | 17793 | | tracingParameters.Add("versionId", versionId); |
| 0 | 17794 | | tracingParameters.Add("hEntityId", hEntityId); |
| 0 | 17795 | | tracingParameters.Add("roleId", roleId); |
| 0 | 17796 | | tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject); |
| 0 | 17797 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 17798 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateHierarchicalEntityRole", tracingParameters); |
| | 17799 | | } |
| | 17800 | | // Construct URL |
| 0 | 17801 | | var _baseUrl = Client.BaseUri; |
| 0 | 17802 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale |
| 0 | 17803 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 17804 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 17805 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 17806 | | _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| 0 | 17807 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 17808 | | // Create HTTP transport objects |
| 0 | 17809 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 17810 | | HttpResponseMessage _httpResponse = null; |
| 0 | 17811 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 0 | 17812 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 17813 | | // Set Headers |
| | 17814 | |
|
| | 17815 | |
|
| 0 | 17816 | | if (customHeaders != null) |
| | 17817 | | { |
| 0 | 17818 | | foreach(var _header in customHeaders) |
| | 17819 | | { |
| 0 | 17820 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 17821 | | { |
| 0 | 17822 | | _httpRequest.Headers.Remove(_header.Key); |
| | 17823 | | } |
| 0 | 17824 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 17825 | | } |
| | 17826 | | } |
| | 17827 | |
|
| | 17828 | | // Serialize Request |
| 0 | 17829 | | string _requestContent = null; |
| 0 | 17830 | | if(entityRoleUpdateObject != null) |
| | 17831 | | { |
| 0 | 17832 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri |
| 0 | 17833 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 0 | 17834 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 17835 | | } |
| | 17836 | | // Set Credentials |
| 0 | 17837 | | if (Client.Credentials != null) |
| | 17838 | | { |
| 0 | 17839 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 17840 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 17841 | | } |
| | 17842 | | // Send Request |
| 0 | 17843 | | if (_shouldTrace) |
| | 17844 | | { |
| 0 | 17845 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 17846 | | } |
| 0 | 17847 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 17848 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 17849 | | if (_shouldTrace) |
| | 17850 | | { |
| 0 | 17851 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 17852 | | } |
| 0 | 17853 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 17854 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 17855 | | string _responseContent = null; |
| 0 | 17856 | | if ((int)_statusCode != 200) |
| | 17857 | | { |
| 0 | 17858 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 17859 | | try |
| | 17860 | | { |
| 0 | 17861 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 17862 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 17863 | | if (_errorBody != null) |
| | 17864 | | { |
| 0 | 17865 | | ex.Body = _errorBody; |
| | 17866 | | } |
| 0 | 17867 | | } |
| 0 | 17868 | | catch (JsonException) |
| | 17869 | | { |
| | 17870 | | // Ignore the exception |
| 0 | 17871 | | } |
| 0 | 17872 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 17873 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 17874 | | if (_shouldTrace) |
| | 17875 | | { |
| 0 | 17876 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 17877 | | } |
| 0 | 17878 | | _httpRequest.Dispose(); |
| 0 | 17879 | | if (_httpResponse != null) |
| | 17880 | | { |
| 0 | 17881 | | _httpResponse.Dispose(); |
| | 17882 | | } |
| 0 | 17883 | | throw ex; |
| | 17884 | | } |
| | 17885 | | // Create Result |
| 0 | 17886 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 0 | 17887 | | _result.Request = _httpRequest; |
| 0 | 17888 | | _result.Response = _httpResponse; |
| | 17889 | | // Deserialize Response |
| 0 | 17890 | | if ((int)_statusCode == 200) |
| | 17891 | | { |
| 0 | 17892 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 17893 | | try |
| | 17894 | | { |
| 0 | 17895 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 0 | 17896 | | } |
| 0 | 17897 | | catch (JsonException ex) |
| | 17898 | | { |
| 0 | 17899 | | _httpRequest.Dispose(); |
| 0 | 17900 | | if (_httpResponse != null) |
| | 17901 | | { |
| 0 | 17902 | | _httpResponse.Dispose(); |
| | 17903 | | } |
| 0 | 17904 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 17905 | | } |
| | 17906 | | } |
| 0 | 17907 | | if (_shouldTrace) |
| | 17908 | | { |
| 0 | 17909 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 17910 | | } |
| 0 | 17911 | | return _result; |
| 0 | 17912 | | } |
| | 17913 | |
|
| | 17914 | | /// <summary> |
| | 17915 | | /// Delete a role for a given hierarchical role in a version of the |
| | 17916 | | /// application. |
| | 17917 | | /// </summary> |
| | 17918 | | /// <param name='appId'> |
| | 17919 | | /// The application ID. |
| | 17920 | | /// </param> |
| | 17921 | | /// <param name='versionId'> |
| | 17922 | | /// The version ID. |
| | 17923 | | /// </param> |
| | 17924 | | /// <param name='hEntityId'> |
| | 17925 | | /// The hierarchical entity extractor ID. |
| | 17926 | | /// </param> |
| | 17927 | | /// <param name='roleId'> |
| | 17928 | | /// The entity role Id. |
| | 17929 | | /// </param> |
| | 17930 | | /// <param name='customHeaders'> |
| | 17931 | | /// Headers that will be added to request. |
| | 17932 | | /// </param> |
| | 17933 | | /// <param name='cancellationToken'> |
| | 17934 | | /// The cancellation token. |
| | 17935 | | /// </param> |
| | 17936 | | /// <exception cref="ErrorResponseException"> |
| | 17937 | | /// Thrown when the operation returned an invalid status code |
| | 17938 | | /// </exception> |
| | 17939 | | /// <exception cref="SerializationException"> |
| | 17940 | | /// Thrown when unable to deserialize the response |
| | 17941 | | /// </exception> |
| | 17942 | | /// <exception cref="ValidationException"> |
| | 17943 | | /// Thrown when a required parameter is null |
| | 17944 | | /// </exception> |
| | 17945 | | /// <exception cref="System.ArgumentNullException"> |
| | 17946 | | /// Thrown when a required parameter is null |
| | 17947 | | /// </exception> |
| | 17948 | | /// <return> |
| | 17949 | | /// A response object containing the response body and response headers. |
| | 17950 | | /// </return> |
| | 17951 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteHierarchicalEntityRoleWithHttpMessagesAsync(Syst |
| | 17952 | | { |
| 0 | 17953 | | if (Client.Endpoint == null) |
| | 17954 | | { |
| 0 | 17955 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 17956 | | } |
| 0 | 17957 | | if (versionId == null) |
| | 17958 | | { |
| 0 | 17959 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 17960 | | } |
| | 17961 | | // Tracing |
| 0 | 17962 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 0 | 17963 | | string _invocationId = null; |
| 0 | 17964 | | if (_shouldTrace) |
| | 17965 | | { |
| 0 | 17966 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 17967 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 17968 | | tracingParameters.Add("appId", appId); |
| 0 | 17969 | | tracingParameters.Add("versionId", versionId); |
| 0 | 17970 | | tracingParameters.Add("hEntityId", hEntityId); |
| 0 | 17971 | | tracingParameters.Add("roleId", roleId); |
| 0 | 17972 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 17973 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteHierarchicalEntityRole", tracingParameters); |
| | 17974 | | } |
| | 17975 | | // Construct URL |
| 0 | 17976 | | var _baseUrl = Client.BaseUri; |
| 0 | 17977 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/hierarchicale |
| 0 | 17978 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 0 | 17979 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 0 | 17980 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 0 | 17981 | | _url = _url.Replace("{hEntityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeO |
| 0 | 17982 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 17983 | | // Create HTTP transport objects |
| 0 | 17984 | | var _httpRequest = new HttpRequestMessage(); |
| 0 | 17985 | | HttpResponseMessage _httpResponse = null; |
| 0 | 17986 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 0 | 17987 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 17988 | | // Set Headers |
| | 17989 | |
|
| | 17990 | |
|
| 0 | 17991 | | if (customHeaders != null) |
| | 17992 | | { |
| 0 | 17993 | | foreach(var _header in customHeaders) |
| | 17994 | | { |
| 0 | 17995 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 17996 | | { |
| 0 | 17997 | | _httpRequest.Headers.Remove(_header.Key); |
| | 17998 | | } |
| 0 | 17999 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 18000 | | } |
| | 18001 | | } |
| | 18002 | |
|
| | 18003 | | // Serialize Request |
| 0 | 18004 | | string _requestContent = null; |
| | 18005 | | // Set Credentials |
| 0 | 18006 | | if (Client.Credentials != null) |
| | 18007 | | { |
| 0 | 18008 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 18009 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 18010 | | } |
| | 18011 | | // Send Request |
| 0 | 18012 | | if (_shouldTrace) |
| | 18013 | | { |
| 0 | 18014 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 18015 | | } |
| 0 | 18016 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 18017 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 0 | 18018 | | if (_shouldTrace) |
| | 18019 | | { |
| 0 | 18020 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 18021 | | } |
| 0 | 18022 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 0 | 18023 | | cancellationToken.ThrowIfCancellationRequested(); |
| 0 | 18024 | | string _responseContent = null; |
| 0 | 18025 | | if ((int)_statusCode != 200) |
| | 18026 | | { |
| 0 | 18027 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 18028 | | try |
| | 18029 | | { |
| 0 | 18030 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 18031 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 18032 | | if (_errorBody != null) |
| | 18033 | | { |
| 0 | 18034 | | ex.Body = _errorBody; |
| | 18035 | | } |
| 0 | 18036 | | } |
| 0 | 18037 | | catch (JsonException) |
| | 18038 | | { |
| | 18039 | | // Ignore the exception |
| 0 | 18040 | | } |
| 0 | 18041 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 18042 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 18043 | | if (_shouldTrace) |
| | 18044 | | { |
| 0 | 18045 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 18046 | | } |
| 0 | 18047 | | _httpRequest.Dispose(); |
| 0 | 18048 | | if (_httpResponse != null) |
| | 18049 | | { |
| 0 | 18050 | | _httpResponse.Dispose(); |
| | 18051 | | } |
| 0 | 18052 | | throw ex; |
| | 18053 | | } |
| | 18054 | | // Create Result |
| 0 | 18055 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 0 | 18056 | | _result.Request = _httpRequest; |
| 0 | 18057 | | _result.Response = _httpResponse; |
| | 18058 | | // Deserialize Response |
| 0 | 18059 | | if ((int)_statusCode == 200) |
| | 18060 | | { |
| 0 | 18061 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 18062 | | try |
| | 18063 | | { |
| 0 | 18064 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 0 | 18065 | | } |
| 0 | 18066 | | catch (JsonException ex) |
| | 18067 | | { |
| 0 | 18068 | | _httpRequest.Dispose(); |
| 0 | 18069 | | if (_httpResponse != null) |
| | 18070 | | { |
| 0 | 18071 | | _httpResponse.Dispose(); |
| | 18072 | | } |
| 0 | 18073 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 18074 | | } |
| | 18075 | | } |
| 0 | 18076 | | if (_shouldTrace) |
| | 18077 | | { |
| 0 | 18078 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 18079 | | } |
| 0 | 18080 | | return _result; |
| 0 | 18081 | | } |
| | 18082 | |
|
| | 18083 | | /// <summary> |
| | 18084 | | /// Get one role for a given prebuilt entity in a version of the application. |
| | 18085 | | /// </summary> |
| | 18086 | | /// <param name='appId'> |
| | 18087 | | /// The application ID. |
| | 18088 | | /// </param> |
| | 18089 | | /// <param name='versionId'> |
| | 18090 | | /// The version ID. |
| | 18091 | | /// </param> |
| | 18092 | | /// <param name='entityId'> |
| | 18093 | | /// entity ID. |
| | 18094 | | /// </param> |
| | 18095 | | /// <param name='roleId'> |
| | 18096 | | /// entity role ID. |
| | 18097 | | /// </param> |
| | 18098 | | /// <param name='customHeaders'> |
| | 18099 | | /// Headers that will be added to request. |
| | 18100 | | /// </param> |
| | 18101 | | /// <param name='cancellationToken'> |
| | 18102 | | /// The cancellation token. |
| | 18103 | | /// </param> |
| | 18104 | | /// <exception cref="ErrorResponseException"> |
| | 18105 | | /// Thrown when the operation returned an invalid status code |
| | 18106 | | /// </exception> |
| | 18107 | | /// <exception cref="SerializationException"> |
| | 18108 | | /// Thrown when unable to deserialize the response |
| | 18109 | | /// </exception> |
| | 18110 | | /// <exception cref="ValidationException"> |
| | 18111 | | /// Thrown when a required parameter is null |
| | 18112 | | /// </exception> |
| | 18113 | | /// <exception cref="System.ArgumentNullException"> |
| | 18114 | | /// Thrown when a required parameter is null |
| | 18115 | | /// </exception> |
| | 18116 | | /// <return> |
| | 18117 | | /// A response object containing the response body and response headers. |
| | 18118 | | /// </return> |
| | 18119 | | public async Task<HttpOperationResponse<EntityRole>> GetCustomEntityRoleWithHttpMessagesAsync(System.Guid appId, |
| | 18120 | | { |
| 2 | 18121 | | if (Client.Endpoint == null) |
| | 18122 | | { |
| 0 | 18123 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 18124 | | } |
| 2 | 18125 | | if (versionId == null) |
| | 18126 | | { |
| 0 | 18127 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 18128 | | } |
| | 18129 | | // Tracing |
| 2 | 18130 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 2 | 18131 | | string _invocationId = null; |
| 2 | 18132 | | if (_shouldTrace) |
| | 18133 | | { |
| 0 | 18134 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 18135 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 18136 | | tracingParameters.Add("appId", appId); |
| 0 | 18137 | | tracingParameters.Add("versionId", versionId); |
| 0 | 18138 | | tracingParameters.Add("entityId", entityId); |
| 0 | 18139 | | tracingParameters.Add("roleId", roleId); |
| 0 | 18140 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 18141 | | ServiceClientTracing.Enter(_invocationId, this, "GetCustomEntityRole", tracingParameters); |
| | 18142 | | } |
| | 18143 | | // Construct URL |
| 2 | 18144 | | var _baseUrl = Client.BaseUri; |
| 2 | 18145 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil |
| 2 | 18146 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 2 | 18147 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 2 | 18148 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 2 | 18149 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 2 | 18150 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 18151 | | // Create HTTP transport objects |
| 2 | 18152 | | var _httpRequest = new HttpRequestMessage(); |
| 2 | 18153 | | HttpResponseMessage _httpResponse = null; |
| 2 | 18154 | | _httpRequest.Method = new HttpMethod("GET"); |
| 2 | 18155 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 18156 | | // Set Headers |
| | 18157 | |
|
| | 18158 | |
|
| 2 | 18159 | | if (customHeaders != null) |
| | 18160 | | { |
| 0 | 18161 | | foreach(var _header in customHeaders) |
| | 18162 | | { |
| 0 | 18163 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 18164 | | { |
| 0 | 18165 | | _httpRequest.Headers.Remove(_header.Key); |
| | 18166 | | } |
| 0 | 18167 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 18168 | | } |
| | 18169 | | } |
| | 18170 | |
|
| | 18171 | | // Serialize Request |
| 2 | 18172 | | string _requestContent = null; |
| | 18173 | | // Set Credentials |
| 2 | 18174 | | if (Client.Credentials != null) |
| | 18175 | | { |
| 2 | 18176 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 18177 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 18178 | | } |
| | 18179 | | // Send Request |
| 2 | 18180 | | if (_shouldTrace) |
| | 18181 | | { |
| 0 | 18182 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 18183 | | } |
| 2 | 18184 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 18185 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 2 | 18186 | | if (_shouldTrace) |
| | 18187 | | { |
| 0 | 18188 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 18189 | | } |
| 2 | 18190 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 2 | 18191 | | cancellationToken.ThrowIfCancellationRequested(); |
| 2 | 18192 | | string _responseContent = null; |
| 2 | 18193 | | if ((int)_statusCode != 200) |
| | 18194 | | { |
| 0 | 18195 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 18196 | | try |
| | 18197 | | { |
| 0 | 18198 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 18199 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 18200 | | if (_errorBody != null) |
| | 18201 | | { |
| 0 | 18202 | | ex.Body = _errorBody; |
| | 18203 | | } |
| 0 | 18204 | | } |
| 0 | 18205 | | catch (JsonException) |
| | 18206 | | { |
| | 18207 | | // Ignore the exception |
| 0 | 18208 | | } |
| 0 | 18209 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 18210 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 18211 | | if (_shouldTrace) |
| | 18212 | | { |
| 0 | 18213 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 18214 | | } |
| 0 | 18215 | | _httpRequest.Dispose(); |
| 0 | 18216 | | if (_httpResponse != null) |
| | 18217 | | { |
| 0 | 18218 | | _httpResponse.Dispose(); |
| | 18219 | | } |
| 0 | 18220 | | throw ex; |
| | 18221 | | } |
| | 18222 | | // Create Result |
| 2 | 18223 | | var _result = new HttpOperationResponse<EntityRole>(); |
| 2 | 18224 | | _result.Request = _httpRequest; |
| 2 | 18225 | | _result.Response = _httpResponse; |
| | 18226 | | // Deserialize Response |
| 2 | 18227 | | if ((int)_statusCode == 200) |
| | 18228 | | { |
| 2 | 18229 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 18230 | | try |
| | 18231 | | { |
| 2 | 18232 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<EntityRole>(_responseContent, Cl |
| 2 | 18233 | | } |
| 0 | 18234 | | catch (JsonException ex) |
| | 18235 | | { |
| 0 | 18236 | | _httpRequest.Dispose(); |
| 0 | 18237 | | if (_httpResponse != null) |
| | 18238 | | { |
| 0 | 18239 | | _httpResponse.Dispose(); |
| | 18240 | | } |
| 0 | 18241 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 18242 | | } |
| | 18243 | | } |
| 2 | 18244 | | if (_shouldTrace) |
| | 18245 | | { |
| 0 | 18246 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 18247 | | } |
| 2 | 18248 | | return _result; |
| 2 | 18249 | | } |
| | 18250 | |
|
| | 18251 | | /// <summary> |
| | 18252 | | /// Update a role for a given prebuilt entity in a version of the application. |
| | 18253 | | /// </summary> |
| | 18254 | | /// <param name='appId'> |
| | 18255 | | /// The application ID. |
| | 18256 | | /// </param> |
| | 18257 | | /// <param name='versionId'> |
| | 18258 | | /// The version ID. |
| | 18259 | | /// </param> |
| | 18260 | | /// <param name='entityId'> |
| | 18261 | | /// The entity ID. |
| | 18262 | | /// </param> |
| | 18263 | | /// <param name='roleId'> |
| | 18264 | | /// The entity role ID. |
| | 18265 | | /// </param> |
| | 18266 | | /// <param name='entityRoleUpdateObject'> |
| | 18267 | | /// The new entity role. |
| | 18268 | | /// </param> |
| | 18269 | | /// <param name='customHeaders'> |
| | 18270 | | /// Headers that will be added to request. |
| | 18271 | | /// </param> |
| | 18272 | | /// <param name='cancellationToken'> |
| | 18273 | | /// The cancellation token. |
| | 18274 | | /// </param> |
| | 18275 | | /// <exception cref="ErrorResponseException"> |
| | 18276 | | /// Thrown when the operation returned an invalid status code |
| | 18277 | | /// </exception> |
| | 18278 | | /// <exception cref="SerializationException"> |
| | 18279 | | /// Thrown when unable to deserialize the response |
| | 18280 | | /// </exception> |
| | 18281 | | /// <exception cref="ValidationException"> |
| | 18282 | | /// Thrown when a required parameter is null |
| | 18283 | | /// </exception> |
| | 18284 | | /// <exception cref="System.ArgumentNullException"> |
| | 18285 | | /// Thrown when a required parameter is null |
| | 18286 | | /// </exception> |
| | 18287 | | /// <return> |
| | 18288 | | /// A response object containing the response body and response headers. |
| | 18289 | | /// </return> |
| | 18290 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateCustomPrebuiltEntityRoleWithHttpMessagesAsync(Sy |
| | 18291 | | { |
| 1 | 18292 | | if (Client.Endpoint == null) |
| | 18293 | | { |
| 0 | 18294 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 18295 | | } |
| 1 | 18296 | | if (versionId == null) |
| | 18297 | | { |
| 0 | 18298 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 18299 | | } |
| 1 | 18300 | | if (entityRoleUpdateObject == null) |
| | 18301 | | { |
| 0 | 18302 | | throw new ValidationException(ValidationRules.CannotBeNull, "entityRoleUpdateObject"); |
| | 18303 | | } |
| | 18304 | | // Tracing |
| 1 | 18305 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 18306 | | string _invocationId = null; |
| 1 | 18307 | | if (_shouldTrace) |
| | 18308 | | { |
| 0 | 18309 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 18310 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 18311 | | tracingParameters.Add("appId", appId); |
| 0 | 18312 | | tracingParameters.Add("versionId", versionId); |
| 0 | 18313 | | tracingParameters.Add("entityId", entityId); |
| 0 | 18314 | | tracingParameters.Add("roleId", roleId); |
| 0 | 18315 | | tracingParameters.Add("entityRoleUpdateObject", entityRoleUpdateObject); |
| 0 | 18316 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 18317 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateCustomPrebuiltEntityRole", tracingParameters); |
| | 18318 | | } |
| | 18319 | | // Construct URL |
| 1 | 18320 | | var _baseUrl = Client.BaseUri; |
| 1 | 18321 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil |
| 1 | 18322 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 18323 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 18324 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 18325 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 18326 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 18327 | | // Create HTTP transport objects |
| 1 | 18328 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 18329 | | HttpResponseMessage _httpResponse = null; |
| 1 | 18330 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 1 | 18331 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 18332 | | // Set Headers |
| | 18333 | |
|
| | 18334 | |
|
| 1 | 18335 | | if (customHeaders != null) |
| | 18336 | | { |
| 0 | 18337 | | foreach(var _header in customHeaders) |
| | 18338 | | { |
| 0 | 18339 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 18340 | | { |
| 0 | 18341 | | _httpRequest.Headers.Remove(_header.Key); |
| | 18342 | | } |
| 0 | 18343 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 18344 | | } |
| | 18345 | | } |
| | 18346 | |
|
| | 18347 | | // Serialize Request |
| 1 | 18348 | | string _requestContent = null; |
| 1 | 18349 | | if(entityRoleUpdateObject != null) |
| | 18350 | | { |
| 1 | 18351 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(entityRoleUpdateObject, Client.Seri |
| 1 | 18352 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 18353 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 18354 | | } |
| | 18355 | | // Set Credentials |
| 1 | 18356 | | if (Client.Credentials != null) |
| | 18357 | | { |
| 1 | 18358 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 18359 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 18360 | | } |
| | 18361 | | // Send Request |
| 1 | 18362 | | if (_shouldTrace) |
| | 18363 | | { |
| 0 | 18364 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 18365 | | } |
| 1 | 18366 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 18367 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 18368 | | if (_shouldTrace) |
| | 18369 | | { |
| 0 | 18370 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 18371 | | } |
| 1 | 18372 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 18373 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 18374 | | string _responseContent = null; |
| 1 | 18375 | | if ((int)_statusCode != 200) |
| | 18376 | | { |
| 0 | 18377 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 18378 | | try |
| | 18379 | | { |
| 0 | 18380 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 18381 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 18382 | | if (_errorBody != null) |
| | 18383 | | { |
| 0 | 18384 | | ex.Body = _errorBody; |
| | 18385 | | } |
| 0 | 18386 | | } |
| 0 | 18387 | | catch (JsonException) |
| | 18388 | | { |
| | 18389 | | // Ignore the exception |
| 0 | 18390 | | } |
| 0 | 18391 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 18392 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 18393 | | if (_shouldTrace) |
| | 18394 | | { |
| 0 | 18395 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 18396 | | } |
| 0 | 18397 | | _httpRequest.Dispose(); |
| 0 | 18398 | | if (_httpResponse != null) |
| | 18399 | | { |
| 0 | 18400 | | _httpResponse.Dispose(); |
| | 18401 | | } |
| 0 | 18402 | | throw ex; |
| | 18403 | | } |
| | 18404 | | // Create Result |
| 1 | 18405 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 18406 | | _result.Request = _httpRequest; |
| 1 | 18407 | | _result.Response = _httpResponse; |
| | 18408 | | // Deserialize Response |
| 1 | 18409 | | if ((int)_statusCode == 200) |
| | 18410 | | { |
| 1 | 18411 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 18412 | | try |
| | 18413 | | { |
| 1 | 18414 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 18415 | | } |
| 0 | 18416 | | catch (JsonException ex) |
| | 18417 | | { |
| 0 | 18418 | | _httpRequest.Dispose(); |
| 0 | 18419 | | if (_httpResponse != null) |
| | 18420 | | { |
| 0 | 18421 | | _httpResponse.Dispose(); |
| | 18422 | | } |
| 0 | 18423 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 18424 | | } |
| | 18425 | | } |
| 1 | 18426 | | if (_shouldTrace) |
| | 18427 | | { |
| 0 | 18428 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 18429 | | } |
| 1 | 18430 | | return _result; |
| 1 | 18431 | | } |
| | 18432 | |
|
| | 18433 | | /// <summary> |
| | 18434 | | /// Delete a role for a given prebuilt entity in a version of the application. |
| | 18435 | | /// </summary> |
| | 18436 | | /// <param name='appId'> |
| | 18437 | | /// The application ID. |
| | 18438 | | /// </param> |
| | 18439 | | /// <param name='versionId'> |
| | 18440 | | /// The version ID. |
| | 18441 | | /// </param> |
| | 18442 | | /// <param name='entityId'> |
| | 18443 | | /// The entity ID. |
| | 18444 | | /// </param> |
| | 18445 | | /// <param name='roleId'> |
| | 18446 | | /// The entity role Id. |
| | 18447 | | /// </param> |
| | 18448 | | /// <param name='customHeaders'> |
| | 18449 | | /// Headers that will be added to request. |
| | 18450 | | /// </param> |
| | 18451 | | /// <param name='cancellationToken'> |
| | 18452 | | /// The cancellation token. |
| | 18453 | | /// </param> |
| | 18454 | | /// <exception cref="ErrorResponseException"> |
| | 18455 | | /// Thrown when the operation returned an invalid status code |
| | 18456 | | /// </exception> |
| | 18457 | | /// <exception cref="SerializationException"> |
| | 18458 | | /// Thrown when unable to deserialize the response |
| | 18459 | | /// </exception> |
| | 18460 | | /// <exception cref="ValidationException"> |
| | 18461 | | /// Thrown when a required parameter is null |
| | 18462 | | /// </exception> |
| | 18463 | | /// <exception cref="System.ArgumentNullException"> |
| | 18464 | | /// Thrown when a required parameter is null |
| | 18465 | | /// </exception> |
| | 18466 | | /// <return> |
| | 18467 | | /// A response object containing the response body and response headers. |
| | 18468 | | /// </return> |
| | 18469 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteCustomEntityRoleWithHttpMessagesAsync(System.Gui |
| | 18470 | | { |
| 1 | 18471 | | if (Client.Endpoint == null) |
| | 18472 | | { |
| 0 | 18473 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 18474 | | } |
| 1 | 18475 | | if (versionId == null) |
| | 18476 | | { |
| 0 | 18477 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 18478 | | } |
| | 18479 | | // Tracing |
| 1 | 18480 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 18481 | | string _invocationId = null; |
| 1 | 18482 | | if (_shouldTrace) |
| | 18483 | | { |
| 0 | 18484 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 18485 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 18486 | | tracingParameters.Add("appId", appId); |
| 0 | 18487 | | tracingParameters.Add("versionId", versionId); |
| 0 | 18488 | | tracingParameters.Add("entityId", entityId); |
| 0 | 18489 | | tracingParameters.Add("roleId", roleId); |
| 0 | 18490 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 18491 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteCustomEntityRole", tracingParameters); |
| | 18492 | | } |
| | 18493 | | // Construct URL |
| 1 | 18494 | | var _baseUrl = Client.BaseUri; |
| 1 | 18495 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/customprebuil |
| 1 | 18496 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 18497 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 18498 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 18499 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 18500 | | _url = _url.Replace("{roleId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 18501 | | // Create HTTP transport objects |
| 1 | 18502 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 18503 | | HttpResponseMessage _httpResponse = null; |
| 1 | 18504 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 1 | 18505 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 18506 | | // Set Headers |
| | 18507 | |
|
| | 18508 | |
|
| 1 | 18509 | | if (customHeaders != null) |
| | 18510 | | { |
| 0 | 18511 | | foreach(var _header in customHeaders) |
| | 18512 | | { |
| 0 | 18513 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 18514 | | { |
| 0 | 18515 | | _httpRequest.Headers.Remove(_header.Key); |
| | 18516 | | } |
| 0 | 18517 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 18518 | | } |
| | 18519 | | } |
| | 18520 | |
|
| | 18521 | | // Serialize Request |
| 1 | 18522 | | string _requestContent = null; |
| | 18523 | | // Set Credentials |
| 1 | 18524 | | if (Client.Credentials != null) |
| | 18525 | | { |
| 1 | 18526 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 18527 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 18528 | | } |
| | 18529 | | // Send Request |
| 1 | 18530 | | if (_shouldTrace) |
| | 18531 | | { |
| 0 | 18532 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 18533 | | } |
| 1 | 18534 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 18535 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 18536 | | if (_shouldTrace) |
| | 18537 | | { |
| 0 | 18538 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 18539 | | } |
| 1 | 18540 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 18541 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 18542 | | string _responseContent = null; |
| 1 | 18543 | | if ((int)_statusCode != 200) |
| | 18544 | | { |
| 0 | 18545 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 18546 | | try |
| | 18547 | | { |
| 0 | 18548 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 18549 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 18550 | | if (_errorBody != null) |
| | 18551 | | { |
| 0 | 18552 | | ex.Body = _errorBody; |
| | 18553 | | } |
| 0 | 18554 | | } |
| 0 | 18555 | | catch (JsonException) |
| | 18556 | | { |
| | 18557 | | // Ignore the exception |
| 0 | 18558 | | } |
| 0 | 18559 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 18560 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 18561 | | if (_shouldTrace) |
| | 18562 | | { |
| 0 | 18563 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 18564 | | } |
| 0 | 18565 | | _httpRequest.Dispose(); |
| 0 | 18566 | | if (_httpResponse != null) |
| | 18567 | | { |
| 0 | 18568 | | _httpResponse.Dispose(); |
| | 18569 | | } |
| 0 | 18570 | | throw ex; |
| | 18571 | | } |
| | 18572 | | // Create Result |
| 1 | 18573 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 18574 | | _result.Request = _httpRequest; |
| 1 | 18575 | | _result.Response = _httpResponse; |
| | 18576 | | // Deserialize Response |
| 1 | 18577 | | if ((int)_statusCode == 200) |
| | 18578 | | { |
| 1 | 18579 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 18580 | | try |
| | 18581 | | { |
| 1 | 18582 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 18583 | | } |
| 0 | 18584 | | catch (JsonException ex) |
| | 18585 | | { |
| 0 | 18586 | | _httpRequest.Dispose(); |
| 0 | 18587 | | if (_httpResponse != null) |
| | 18588 | | { |
| 0 | 18589 | | _httpResponse.Dispose(); |
| | 18590 | | } |
| 0 | 18591 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 18592 | | } |
| | 18593 | | } |
| 1 | 18594 | | if (_shouldTrace) |
| | 18595 | | { |
| 0 | 18596 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 18597 | | } |
| 1 | 18598 | | return _result; |
| 1 | 18599 | | } |
| | 18600 | |
|
| | 18601 | | /// <summary> |
| | 18602 | | /// Get the explicit (exception) list of the pattern.any entity in a version of |
| | 18603 | | /// the application. |
| | 18604 | | /// </summary> |
| | 18605 | | /// <param name='appId'> |
| | 18606 | | /// The application ID. |
| | 18607 | | /// </param> |
| | 18608 | | /// <param name='versionId'> |
| | 18609 | | /// The version ID. |
| | 18610 | | /// </param> |
| | 18611 | | /// <param name='entityId'> |
| | 18612 | | /// The Pattern.Any entity Id. |
| | 18613 | | /// </param> |
| | 18614 | | /// <param name='itemId'> |
| | 18615 | | /// The explicit list item Id. |
| | 18616 | | /// </param> |
| | 18617 | | /// <param name='customHeaders'> |
| | 18618 | | /// Headers that will be added to request. |
| | 18619 | | /// </param> |
| | 18620 | | /// <param name='cancellationToken'> |
| | 18621 | | /// The cancellation token. |
| | 18622 | | /// </param> |
| | 18623 | | /// <exception cref="ErrorResponseException"> |
| | 18624 | | /// Thrown when the operation returned an invalid status code |
| | 18625 | | /// </exception> |
| | 18626 | | /// <exception cref="SerializationException"> |
| | 18627 | | /// Thrown when unable to deserialize the response |
| | 18628 | | /// </exception> |
| | 18629 | | /// <exception cref="ValidationException"> |
| | 18630 | | /// Thrown when a required parameter is null |
| | 18631 | | /// </exception> |
| | 18632 | | /// <exception cref="System.ArgumentNullException"> |
| | 18633 | | /// Thrown when a required parameter is null |
| | 18634 | | /// </exception> |
| | 18635 | | /// <return> |
| | 18636 | | /// A response object containing the response body and response headers. |
| | 18637 | | /// </return> |
| | 18638 | | public async Task<HttpOperationResponse<ExplicitListItem>> GetExplicitListItemWithHttpMessagesAsync(System.Guid |
| | 18639 | | { |
| 3 | 18640 | | if (Client.Endpoint == null) |
| | 18641 | | { |
| 0 | 18642 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 18643 | | } |
| 3 | 18644 | | if (versionId == null) |
| | 18645 | | { |
| 0 | 18646 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 18647 | | } |
| | 18648 | | // Tracing |
| 3 | 18649 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 3 | 18650 | | string _invocationId = null; |
| 3 | 18651 | | if (_shouldTrace) |
| | 18652 | | { |
| 0 | 18653 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 18654 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 18655 | | tracingParameters.Add("appId", appId); |
| 0 | 18656 | | tracingParameters.Add("versionId", versionId); |
| 0 | 18657 | | tracingParameters.Add("entityId", entityId); |
| 0 | 18658 | | tracingParameters.Add("itemId", itemId); |
| 0 | 18659 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 18660 | | ServiceClientTracing.Enter(_invocationId, this, "GetExplicitListItem", tracingParameters); |
| | 18661 | | } |
| | 18662 | | // Construct URL |
| 3 | 18663 | | var _baseUrl = Client.BaseUri; |
| 3 | 18664 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 3 | 18665 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 3 | 18666 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 3 | 18667 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 3 | 18668 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 3 | 18669 | | _url = _url.Replace("{itemId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 18670 | | // Create HTTP transport objects |
| 3 | 18671 | | var _httpRequest = new HttpRequestMessage(); |
| 3 | 18672 | | HttpResponseMessage _httpResponse = null; |
| 3 | 18673 | | _httpRequest.Method = new HttpMethod("GET"); |
| 3 | 18674 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 18675 | | // Set Headers |
| | 18676 | |
|
| | 18677 | |
|
| 3 | 18678 | | if (customHeaders != null) |
| | 18679 | | { |
| 0 | 18680 | | foreach(var _header in customHeaders) |
| | 18681 | | { |
| 0 | 18682 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 18683 | | { |
| 0 | 18684 | | _httpRequest.Headers.Remove(_header.Key); |
| | 18685 | | } |
| 0 | 18686 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 18687 | | } |
| | 18688 | | } |
| | 18689 | |
|
| | 18690 | | // Serialize Request |
| 3 | 18691 | | string _requestContent = null; |
| | 18692 | | // Set Credentials |
| 3 | 18693 | | if (Client.Credentials != null) |
| | 18694 | | { |
| 3 | 18695 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 18696 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 18697 | | } |
| | 18698 | | // Send Request |
| 3 | 18699 | | if (_shouldTrace) |
| | 18700 | | { |
| 0 | 18701 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 18702 | | } |
| 3 | 18703 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 18704 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 3 | 18705 | | if (_shouldTrace) |
| | 18706 | | { |
| 0 | 18707 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 18708 | | } |
| 3 | 18709 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 3 | 18710 | | cancellationToken.ThrowIfCancellationRequested(); |
| 3 | 18711 | | string _responseContent = null; |
| 3 | 18712 | | if ((int)_statusCode != 200) |
| | 18713 | | { |
| 0 | 18714 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 18715 | | try |
| | 18716 | | { |
| 0 | 18717 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 18718 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 18719 | | if (_errorBody != null) |
| | 18720 | | { |
| 0 | 18721 | | ex.Body = _errorBody; |
| | 18722 | | } |
| 0 | 18723 | | } |
| 0 | 18724 | | catch (JsonException) |
| | 18725 | | { |
| | 18726 | | // Ignore the exception |
| 0 | 18727 | | } |
| 0 | 18728 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 18729 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 18730 | | if (_shouldTrace) |
| | 18731 | | { |
| 0 | 18732 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 18733 | | } |
| 0 | 18734 | | _httpRequest.Dispose(); |
| 0 | 18735 | | if (_httpResponse != null) |
| | 18736 | | { |
| 0 | 18737 | | _httpResponse.Dispose(); |
| | 18738 | | } |
| 0 | 18739 | | throw ex; |
| | 18740 | | } |
| | 18741 | | // Create Result |
| 3 | 18742 | | var _result = new HttpOperationResponse<ExplicitListItem>(); |
| 3 | 18743 | | _result.Request = _httpRequest; |
| 3 | 18744 | | _result.Response = _httpResponse; |
| | 18745 | | // Deserialize Response |
| 3 | 18746 | | if ((int)_statusCode == 200) |
| | 18747 | | { |
| 3 | 18748 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 18749 | | try |
| | 18750 | | { |
| 3 | 18751 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ExplicitListItem>(_responseConte |
| 3 | 18752 | | } |
| 0 | 18753 | | catch (JsonException ex) |
| | 18754 | | { |
| 0 | 18755 | | _httpRequest.Dispose(); |
| 0 | 18756 | | if (_httpResponse != null) |
| | 18757 | | { |
| 0 | 18758 | | _httpResponse.Dispose(); |
| | 18759 | | } |
| 0 | 18760 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 18761 | | } |
| | 18762 | | } |
| 3 | 18763 | | if (_shouldTrace) |
| | 18764 | | { |
| 0 | 18765 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 18766 | | } |
| 3 | 18767 | | return _result; |
| 3 | 18768 | | } |
| | 18769 | |
|
| | 18770 | | /// <summary> |
| | 18771 | | /// Updates an explicit (exception) list item for a Pattern.Any entity in a |
| | 18772 | | /// version of the application. |
| | 18773 | | /// </summary> |
| | 18774 | | /// <param name='appId'> |
| | 18775 | | /// The application ID. |
| | 18776 | | /// </param> |
| | 18777 | | /// <param name='versionId'> |
| | 18778 | | /// The version ID. |
| | 18779 | | /// </param> |
| | 18780 | | /// <param name='entityId'> |
| | 18781 | | /// The Pattern.Any entity extractor ID. |
| | 18782 | | /// </param> |
| | 18783 | | /// <param name='itemId'> |
| | 18784 | | /// The explicit list item ID. |
| | 18785 | | /// </param> |
| | 18786 | | /// <param name='item'> |
| | 18787 | | /// The new explicit list item. |
| | 18788 | | /// </param> |
| | 18789 | | /// <param name='customHeaders'> |
| | 18790 | | /// Headers that will be added to request. |
| | 18791 | | /// </param> |
| | 18792 | | /// <param name='cancellationToken'> |
| | 18793 | | /// The cancellation token. |
| | 18794 | | /// </param> |
| | 18795 | | /// <exception cref="ErrorResponseException"> |
| | 18796 | | /// Thrown when the operation returned an invalid status code |
| | 18797 | | /// </exception> |
| | 18798 | | /// <exception cref="SerializationException"> |
| | 18799 | | /// Thrown when unable to deserialize the response |
| | 18800 | | /// </exception> |
| | 18801 | | /// <exception cref="ValidationException"> |
| | 18802 | | /// Thrown when a required parameter is null |
| | 18803 | | /// </exception> |
| | 18804 | | /// <exception cref="System.ArgumentNullException"> |
| | 18805 | | /// Thrown when a required parameter is null |
| | 18806 | | /// </exception> |
| | 18807 | | /// <return> |
| | 18808 | | /// A response object containing the response body and response headers. |
| | 18809 | | /// </return> |
| | 18810 | | public async Task<HttpOperationResponse<OperationStatus>> UpdateExplicitListItemWithHttpMessagesAsync(System.Gui |
| | 18811 | | { |
| 1 | 18812 | | if (Client.Endpoint == null) |
| | 18813 | | { |
| 0 | 18814 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 18815 | | } |
| 1 | 18816 | | if (versionId == null) |
| | 18817 | | { |
| 0 | 18818 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 18819 | | } |
| 1 | 18820 | | if (item == null) |
| | 18821 | | { |
| 0 | 18822 | | throw new ValidationException(ValidationRules.CannotBeNull, "item"); |
| | 18823 | | } |
| | 18824 | | // Tracing |
| 1 | 18825 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 18826 | | string _invocationId = null; |
| 1 | 18827 | | if (_shouldTrace) |
| | 18828 | | { |
| 0 | 18829 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 18830 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 18831 | | tracingParameters.Add("appId", appId); |
| 0 | 18832 | | tracingParameters.Add("versionId", versionId); |
| 0 | 18833 | | tracingParameters.Add("entityId", entityId); |
| 0 | 18834 | | tracingParameters.Add("itemId", itemId); |
| 0 | 18835 | | tracingParameters.Add("item", item); |
| 0 | 18836 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 18837 | | ServiceClientTracing.Enter(_invocationId, this, "UpdateExplicitListItem", tracingParameters); |
| | 18838 | | } |
| | 18839 | | // Construct URL |
| 1 | 18840 | | var _baseUrl = Client.BaseUri; |
| 1 | 18841 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 1 | 18842 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 18843 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 18844 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 18845 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 18846 | | _url = _url.Replace("{itemId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 18847 | | // Create HTTP transport objects |
| 1 | 18848 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 18849 | | HttpResponseMessage _httpResponse = null; |
| 1 | 18850 | | _httpRequest.Method = new HttpMethod("PUT"); |
| 1 | 18851 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 18852 | | // Set Headers |
| | 18853 | |
|
| | 18854 | |
|
| 1 | 18855 | | if (customHeaders != null) |
| | 18856 | | { |
| 0 | 18857 | | foreach(var _header in customHeaders) |
| | 18858 | | { |
| 0 | 18859 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 18860 | | { |
| 0 | 18861 | | _httpRequest.Headers.Remove(_header.Key); |
| | 18862 | | } |
| 0 | 18863 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 18864 | | } |
| | 18865 | | } |
| | 18866 | |
|
| | 18867 | | // Serialize Request |
| 1 | 18868 | | string _requestContent = null; |
| 1 | 18869 | | if(item != null) |
| | 18870 | | { |
| 1 | 18871 | | _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(item, Client.SerializationSettings) |
| 1 | 18872 | | _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); |
| 1 | 18873 | | _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("applicatio |
| | 18874 | | } |
| | 18875 | | // Set Credentials |
| 1 | 18876 | | if (Client.Credentials != null) |
| | 18877 | | { |
| 1 | 18878 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 18879 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 18880 | | } |
| | 18881 | | // Send Request |
| 1 | 18882 | | if (_shouldTrace) |
| | 18883 | | { |
| 0 | 18884 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 18885 | | } |
| 1 | 18886 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 18887 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 18888 | | if (_shouldTrace) |
| | 18889 | | { |
| 0 | 18890 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 18891 | | } |
| 1 | 18892 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 18893 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 18894 | | string _responseContent = null; |
| 1 | 18895 | | if ((int)_statusCode != 200) |
| | 18896 | | { |
| 0 | 18897 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 18898 | | try |
| | 18899 | | { |
| 0 | 18900 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 18901 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 18902 | | if (_errorBody != null) |
| | 18903 | | { |
| 0 | 18904 | | ex.Body = _errorBody; |
| | 18905 | | } |
| 0 | 18906 | | } |
| 0 | 18907 | | catch (JsonException) |
| | 18908 | | { |
| | 18909 | | // Ignore the exception |
| 0 | 18910 | | } |
| 0 | 18911 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 18912 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 18913 | | if (_shouldTrace) |
| | 18914 | | { |
| 0 | 18915 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 18916 | | } |
| 0 | 18917 | | _httpRequest.Dispose(); |
| 0 | 18918 | | if (_httpResponse != null) |
| | 18919 | | { |
| 0 | 18920 | | _httpResponse.Dispose(); |
| | 18921 | | } |
| 0 | 18922 | | throw ex; |
| | 18923 | | } |
| | 18924 | | // Create Result |
| 1 | 18925 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 18926 | | _result.Request = _httpRequest; |
| 1 | 18927 | | _result.Response = _httpResponse; |
| | 18928 | | // Deserialize Response |
| 1 | 18929 | | if ((int)_statusCode == 200) |
| | 18930 | | { |
| 1 | 18931 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 18932 | | try |
| | 18933 | | { |
| 1 | 18934 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 18935 | | } |
| 0 | 18936 | | catch (JsonException ex) |
| | 18937 | | { |
| 0 | 18938 | | _httpRequest.Dispose(); |
| 0 | 18939 | | if (_httpResponse != null) |
| | 18940 | | { |
| 0 | 18941 | | _httpResponse.Dispose(); |
| | 18942 | | } |
| 0 | 18943 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 18944 | | } |
| | 18945 | | } |
| 1 | 18946 | | if (_shouldTrace) |
| | 18947 | | { |
| 0 | 18948 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 18949 | | } |
| 1 | 18950 | | return _result; |
| 1 | 18951 | | } |
| | 18952 | |
|
| | 18953 | | /// <summary> |
| | 18954 | | /// Delete an item from the explicit (exception) list for a Pattern.any entity |
| | 18955 | | /// in a version of the application. |
| | 18956 | | /// </summary> |
| | 18957 | | /// <param name='appId'> |
| | 18958 | | /// The application ID. |
| | 18959 | | /// </param> |
| | 18960 | | /// <param name='versionId'> |
| | 18961 | | /// The version ID. |
| | 18962 | | /// </param> |
| | 18963 | | /// <param name='entityId'> |
| | 18964 | | /// The pattern.any entity id. |
| | 18965 | | /// </param> |
| | 18966 | | /// <param name='itemId'> |
| | 18967 | | /// The explicit list item which will be deleted. |
| | 18968 | | /// </param> |
| | 18969 | | /// <param name='customHeaders'> |
| | 18970 | | /// Headers that will be added to request. |
| | 18971 | | /// </param> |
| | 18972 | | /// <param name='cancellationToken'> |
| | 18973 | | /// The cancellation token. |
| | 18974 | | /// </param> |
| | 18975 | | /// <exception cref="ErrorResponseException"> |
| | 18976 | | /// Thrown when the operation returned an invalid status code |
| | 18977 | | /// </exception> |
| | 18978 | | /// <exception cref="SerializationException"> |
| | 18979 | | /// Thrown when unable to deserialize the response |
| | 18980 | | /// </exception> |
| | 18981 | | /// <exception cref="ValidationException"> |
| | 18982 | | /// Thrown when a required parameter is null |
| | 18983 | | /// </exception> |
| | 18984 | | /// <exception cref="System.ArgumentNullException"> |
| | 18985 | | /// Thrown when a required parameter is null |
| | 18986 | | /// </exception> |
| | 18987 | | /// <return> |
| | 18988 | | /// A response object containing the response body and response headers. |
| | 18989 | | /// </return> |
| | 18990 | | public async Task<HttpOperationResponse<OperationStatus>> DeleteExplicitListItemWithHttpMessagesAsync(System.Gui |
| | 18991 | | { |
| 1 | 18992 | | if (Client.Endpoint == null) |
| | 18993 | | { |
| 0 | 18994 | | throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint"); |
| | 18995 | | } |
| 1 | 18996 | | if (versionId == null) |
| | 18997 | | { |
| 0 | 18998 | | throw new ValidationException(ValidationRules.CannotBeNull, "versionId"); |
| | 18999 | | } |
| | 19000 | | // Tracing |
| 1 | 19001 | | bool _shouldTrace = ServiceClientTracing.IsEnabled; |
| 1 | 19002 | | string _invocationId = null; |
| 1 | 19003 | | if (_shouldTrace) |
| | 19004 | | { |
| 0 | 19005 | | _invocationId = ServiceClientTracing.NextInvocationId.ToString(); |
| 0 | 19006 | | Dictionary<string, object> tracingParameters = new Dictionary<string, object>(); |
| 0 | 19007 | | tracingParameters.Add("appId", appId); |
| 0 | 19008 | | tracingParameters.Add("versionId", versionId); |
| 0 | 19009 | | tracingParameters.Add("entityId", entityId); |
| 0 | 19010 | | tracingParameters.Add("itemId", itemId); |
| 0 | 19011 | | tracingParameters.Add("cancellationToken", cancellationToken); |
| 0 | 19012 | | ServiceClientTracing.Enter(_invocationId, this, "DeleteExplicitListItem", tracingParameters); |
| | 19013 | | } |
| | 19014 | | // Construct URL |
| 1 | 19015 | | var _baseUrl = Client.BaseUri; |
| 1 | 19016 | | var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "apps/{appId}/versions/{versionId}/patternanyent |
| 1 | 19017 | | _url = _url.Replace("{Endpoint}", Client.Endpoint); |
| 1 | 19018 | | _url = _url.Replace("{appId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObjec |
| 1 | 19019 | | _url = _url.Replace("{versionId}", System.Uri.EscapeDataString(versionId)); |
| 1 | 19020 | | _url = _url.Replace("{entityId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeOb |
| 1 | 19021 | | _url = _url.Replace("{itemId}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObje |
| | 19022 | | // Create HTTP transport objects |
| 1 | 19023 | | var _httpRequest = new HttpRequestMessage(); |
| 1 | 19024 | | HttpResponseMessage _httpResponse = null; |
| 1 | 19025 | | _httpRequest.Method = new HttpMethod("DELETE"); |
| 1 | 19026 | | _httpRequest.RequestUri = new System.Uri(_url); |
| | 19027 | | // Set Headers |
| | 19028 | |
|
| | 19029 | |
|
| 1 | 19030 | | if (customHeaders != null) |
| | 19031 | | { |
| 0 | 19032 | | foreach(var _header in customHeaders) |
| | 19033 | | { |
| 0 | 19034 | | if (_httpRequest.Headers.Contains(_header.Key)) |
| | 19035 | | { |
| 0 | 19036 | | _httpRequest.Headers.Remove(_header.Key); |
| | 19037 | | } |
| 0 | 19038 | | _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); |
| | 19039 | | } |
| | 19040 | | } |
| | 19041 | |
|
| | 19042 | | // Serialize Request |
| 1 | 19043 | | string _requestContent = null; |
| | 19044 | | // Set Credentials |
| 1 | 19045 | | if (Client.Credentials != null) |
| | 19046 | | { |
| 1 | 19047 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 19048 | | await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| | 19049 | | } |
| | 19050 | | // Send Request |
| 1 | 19051 | | if (_shouldTrace) |
| | 19052 | | { |
| 0 | 19053 | | ServiceClientTracing.SendRequest(_invocationId, _httpRequest); |
| | 19054 | | } |
| 1 | 19055 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 19056 | | _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); |
| 1 | 19057 | | if (_shouldTrace) |
| | 19058 | | { |
| 0 | 19059 | | ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); |
| | 19060 | | } |
| 1 | 19061 | | HttpStatusCode _statusCode = _httpResponse.StatusCode; |
| 1 | 19062 | | cancellationToken.ThrowIfCancellationRequested(); |
| 1 | 19063 | | string _responseContent = null; |
| 1 | 19064 | | if ((int)_statusCode != 200) |
| | 19065 | | { |
| 0 | 19066 | | var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _st |
| | 19067 | | try |
| | 19068 | | { |
| 0 | 19069 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| 0 | 19070 | | ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_res |
| 0 | 19071 | | if (_errorBody != null) |
| | 19072 | | { |
| 0 | 19073 | | ex.Body = _errorBody; |
| | 19074 | | } |
| 0 | 19075 | | } |
| 0 | 19076 | | catch (JsonException) |
| | 19077 | | { |
| | 19078 | | // Ignore the exception |
| 0 | 19079 | | } |
| 0 | 19080 | | ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); |
| 0 | 19081 | | ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); |
| 0 | 19082 | | if (_shouldTrace) |
| | 19083 | | { |
| 0 | 19084 | | ServiceClientTracing.Error(_invocationId, ex); |
| | 19085 | | } |
| 0 | 19086 | | _httpRequest.Dispose(); |
| 0 | 19087 | | if (_httpResponse != null) |
| | 19088 | | { |
| 0 | 19089 | | _httpResponse.Dispose(); |
| | 19090 | | } |
| 0 | 19091 | | throw ex; |
| | 19092 | | } |
| | 19093 | | // Create Result |
| 1 | 19094 | | var _result = new HttpOperationResponse<OperationStatus>(); |
| 1 | 19095 | | _result.Request = _httpRequest; |
| 1 | 19096 | | _result.Response = _httpResponse; |
| | 19097 | | // Deserialize Response |
| 1 | 19098 | | if ((int)_statusCode == 200) |
| | 19099 | | { |
| 1 | 19100 | | _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); |
| | 19101 | | try |
| | 19102 | | { |
| 1 | 19103 | | _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<OperationStatus>(_responseConten |
| 1 | 19104 | | } |
| 0 | 19105 | | catch (JsonException ex) |
| | 19106 | | { |
| 0 | 19107 | | _httpRequest.Dispose(); |
| 0 | 19108 | | if (_httpResponse != null) |
| | 19109 | | { |
| 0 | 19110 | | _httpResponse.Dispose(); |
| | 19111 | | } |
| 0 | 19112 | | throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); |
| | 19113 | | } |
| | 19114 | | } |
| 1 | 19115 | | if (_shouldTrace) |
| | 19116 | | { |
| 0 | 19117 | | ServiceClientTracing.Exit(_invocationId, _result); |
| | 19118 | | } |
| 1 | 19119 | | return _result; |
| 1 | 19120 | | } |
| | 19121 | |
|
| | 19122 | | } |
| | 19123 | | } |