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

https://gitlab.com/github-cloud-corp/aws-sdk-net · C# · 145 lines · 100 code · 10 blank · 35 comment · 17 complexity · a1a7a1891134147c7b39efc40c48b728 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 GetApiKey operation
  35. /// </summary>
  36. public class GetApiKeyResponseUnmarshaller : 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. GetApiKeyResponse response = new GetApiKeyResponse();
  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("NotFoundException"))
  106. {
  107. return new NotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
  108. }
  109. if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyRequestsException"))
  110. {
  111. return new TooManyRequestsException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
  112. }
  113. if (errorResponse.Code != null && errorResponse.Code.Equals("UnauthorizedException"))
  114. {
  115. return new UnauthorizedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
  116. }
  117. return new AmazonAPIGatewayException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
  118. }
  119. private static GetApiKeyResponseUnmarshaller _instance = new GetApiKeyResponseUnmarshaller();
  120. internal static GetApiKeyResponseUnmarshaller GetInstance()
  121. {
  122. return _instance;
  123. }
  124. /// <summary>
  125. /// Gets the singleton.
  126. /// </summary>
  127. public static GetApiKeyResponseUnmarshaller Instance
  128. {
  129. get
  130. {
  131. return _instance;
  132. }
  133. }
  134. }
  135. }