/sdk/src/Services/APIGateway/Generated/Model/Internal/MarshallTransformations/UpdateApiKeyResponseUnmarshaller.cs

https://gitlab.com/vectorci/aws-sdk-net · C# · 149 lines · 104 code · 10 blank · 35 comment · 20 complexity · 3a69942a49614158a5a4e40f69af520a MD5 · raw file

  1. /*
  2. * Copyright 2010-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License").
  5. * You may not use this file except in compliance with the License.
  6. * A copy of the License is located at
  7. *
  8. * http://aws.amazon.com/apache2.0
  9. *
  10. * or in the "license" file accompanying this file. This file is distributed
  11. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12. * express or implied. See the License for the specific language governing
  13. * permissions and limitations under the License.
  14. */
  15. /*
  16. * Do not modify this file. This file is generated from the apigateway-2015-07-09.normal.json service model.
  17. */
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Globalization;
  21. using System.IO;
  22. using System.Net;
  23. using System.Text;
  24. using System.Xml.Serialization;
  25. using Amazon.APIGateway.Model;
  26. using Amazon.Runtime;
  27. using Amazon.Runtime.Internal;
  28. using Amazon.Runtime.Internal.Transform;
  29. using Amazon.Runtime.Internal.Util;
  30. using ThirdParty.Json.LitJson;
  31. namespace Amazon.APIGateway.Model.Internal.MarshallTransformations
  32. {
  33. /// <summary>
  34. /// Response Unmarshaller for UpdateApiKey operation
  35. /// </summary>
  36. public class UpdateApiKeyResponseUnmarshaller : JsonResponseUnmarshaller
  37. {
  38. /// <summary>
  39. /// Unmarshaller the response from the service to the response class.
  40. /// </summary>
  41. /// <param name="context"></param>
  42. /// <returns></returns>
  43. public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
  44. {
  45. UpdateApiKeyResponse response = new UpdateApiKeyResponse();
  46. context.Read();
  47. int targetDepth = context.CurrentDepth;
  48. while (context.ReadAtDepth(targetDepth))
  49. {
  50. if (context.TestExpression("createdDate", targetDepth))
  51. {
  52. var unmarshaller = DateTimeUnmarshaller.Instance;
  53. response.CreatedDate = unmarshaller.Unmarshall(context);
  54. continue;
  55. }
  56. if (context.TestExpression("description", targetDepth))
  57. {
  58. var unmarshaller = StringUnmarshaller.Instance;
  59. response.Description = unmarshaller.Unmarshall(context);
  60. continue;
  61. }
  62. if (context.TestExpression("enabled", targetDepth))
  63. {
  64. var unmarshaller = BoolUnmarshaller.Instance;
  65. response.Enabled = unmarshaller.Unmarshall(context);
  66. continue;
  67. }
  68. if (context.TestExpression("id", targetDepth))
  69. {
  70. var unmarshaller = StringUnmarshaller.Instance;
  71. response.Id = unmarshaller.Unmarshall(context);
  72. continue;
  73. }
  74. if (context.TestExpression("lastUpdatedDate", targetDepth))
  75. {
  76. var unmarshaller = DateTimeUnmarshaller.Instance;
  77. response.LastUpdatedDate = unmarshaller.Unmarshall(context);
  78. continue;
  79. }
  80. if (context.TestExpression("name", targetDepth))
  81. {
  82. var unmarshaller = StringUnmarshaller.Instance;
  83. response.Name = unmarshaller.Unmarshall(context);
  84. continue;
  85. }
  86. if (context.TestExpression("stageKeys", targetDepth))
  87. {
  88. var unmarshaller = new ListUnmarshaller<string, StringUnmarshaller>(StringUnmarshaller.Instance);
  89. response.StageKeys = unmarshaller.Unmarshall(context);
  90. continue;
  91. }
  92. }
  93. return response;
  94. }
  95. /// <summary>
  96. /// Unmarshaller error response to exception.
  97. /// </summary>
  98. /// <param name="context"></param>
  99. /// <param name="innerException"></param>
  100. /// <param name="statusCode"></param>
  101. /// <returns></returns>
  102. public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
  103. {
  104. ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
  105. if (errorResponse.Code != null && errorResponse.Code.Equals("BadRequestException"))
  106. {
  107. return new BadRequestException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
  108. }
  109. if (errorResponse.Code != null && errorResponse.Code.Equals("NotFoundException"))
  110. {
  111. return new NotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
  112. }
  113. if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyRequestsException"))
  114. {
  115. return new TooManyRequestsException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
  116. }
  117. if (errorResponse.Code != null && errorResponse.Code.Equals("UnauthorizedException"))
  118. {
  119. return new UnauthorizedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
  120. }
  121. return new AmazonAPIGatewayException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
  122. }
  123. private static UpdateApiKeyResponseUnmarshaller _instance = new UpdateApiKeyResponseUnmarshaller();
  124. internal static UpdateApiKeyResponseUnmarshaller GetInstance()
  125. {
  126. return _instance;
  127. }
  128. /// <summary>
  129. /// Gets the singleton.
  130. /// </summary>
  131. public static UpdateApiKeyResponseUnmarshaller Instance
  132. {
  133. get
  134. {
  135. return _instance;
  136. }
  137. }
  138. }
  139. }