/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetUsageResponse response = new GetUsageResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("endDate", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.EndDate = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("values", targetDepth)) { var unmarshaller = new DictionaryUnmarshaller <string, List <List <long> >, StringUnmarshaller, ListUnmarshaller <List <long>, ListUnmarshaller <long, LongUnmarshaller> > >(StringUnmarshaller.Instance, new ListUnmarshaller <List <long>, ListUnmarshaller <long, LongUnmarshaller> >(new ListUnmarshaller <long, LongUnmarshaller>(LongUnmarshaller.Instance))); response.Items = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("position", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Position = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("startDate", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.StartDate = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("usagePlanId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.UsagePlanId = unmarshaller.Unmarshall(context); continue; } } return(response); }
public async Task <GetUsageResponse> GetUsageAsync(CancellationToken cancellationToken = default) { var request = InitRequest("getUsage"); ResponseBase responseBase = await MakegRpcRequestAsync(request, cancellationToken).ConfigureAwait(false); GetUsageResponse response = _mapper.Map <GetUsageResponse>(responseBase); response.ResultInfo.CreationTime = DateTime.Parse(response.ResultInfo.StringCreationTime, null, DateTimeStyles.RoundtripKind); if (response.ResultInfo.StringStatus.Equals("running")) { response.ResultInfo.Status = Status.Running; } else { response.ResultInfo.Status = Status.Stopped; } return(response); }