/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { ListLocalDisksResponse response = new ListLocalDisksResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Disks", targetDepth)) { var unmarshaller = new ListUnmarshaller <Disk, DiskUnmarshaller>(DiskUnmarshaller.Instance); response.Disks = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("GatewayARN", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.GatewayARN = unmarshaller.Unmarshall(context); continue; } } return(response); }
public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { ListLocalDisksResponse response = new ListLocalDisksResponse(); context.Read(); response.ListLocalDisksResult = ListLocalDisksResultUnmarshaller.GetInstance().Unmarshall(context); return(response); }
public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { ListLocalDisksResponse response = new ListLocalDisksResponse(); context.Read(); UnmarshallResult(context, response); return(response); }
private static void UnmarshallResult(JsonUnmarshallerContext context, ListLocalDisksResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; while (context.Read()) { if (context.TestExpression("GatewayARN", targetDepth)) { context.Read(); response.GatewayARN = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("Disks", targetDepth)) { context.Read(); response.Disks = new List <Disk>(); DiskUnmarshaller unmarshaller = DiskUnmarshaller.GetInstance(); while (context.Read()) { JsonToken token = context.CurrentTokenType; if (token == JsonToken.ArrayStart) { continue; } if (token == JsonToken.ArrayEnd) { break; } response.Disks.Add(unmarshaller.Unmarshall(context)); } continue; } if (context.CurrentDepth <= originalDepth) { return; } } return; }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonStorageGatewayConfig config = new AmazonStorageGatewayConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonStorageGatewayClient client = new AmazonStorageGatewayClient(creds, config); ListLocalDisksResponse resp = new ListLocalDisksResponse(); ListLocalDisksRequest req = new ListLocalDisksRequest { }; resp = client.ListLocalDisks(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.Disks) { AddObject(obj); } }