public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { DescribeTagsResponse response = new DescribeTagsResponse(); int targetDepth = 2; while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("tagSet/item", targetDepth)) { response.Tags.Add(TagDescriptionUnmarshaller.GetInstance().Unmarshall(context)); continue; } if (context.TestExpression("nextToken", targetDepth)) { response.NextToken = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } } } return response; }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { DescribeTagsResponse response = new DescribeTagsResponse(); int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) targetDepth = 2; while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("nextToken", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextToken = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("tagSet/item", targetDepth)) { var unmarshaller = TagDescriptionUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.Tags.Add(item); continue; } } } return response; }
public static void GetTopology() { IAmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client(); IAmazonAutoScaling asg = AWSClientFactory.CreateAmazonAutoScalingClient(); IAmazonElasticLoadBalancing elb = AWSClientFactory.CreateAmazonElasticLoadBalancingClient(); DescribeVpcsResponse vpcResponse = ec2.DescribeVpcs(); WriteFile("vpcs.csv", vpcResponse.Vpcs); DescribeInstancesResponse instanceResponse = ec2.DescribeInstances(); var reservationIndex = 0; foreach (var reservation in instanceResponse.Reservations) { if (reservationIndex == 0) { WriteFile("instances.csv", reservation.Instances); } else { AppendFile("instances.csv", reservation.Instances); } reservationIndex++; } DescribeNetworkAclsResponse naclResponse = ec2.DescribeNetworkAcls(); WriteFile("nacls.csv", naclResponse.NetworkAcls); Amazon.EC2.Model.DescribeTagsResponse tagsResponse = ec2.DescribeTags(); WriteFile("tags.csv", tagsResponse.Tags); DescribeVolumesResponse volumesResponse = ec2.DescribeVolumes(); WriteFile("volumes.csv", volumesResponse.Volumes); DescribeLoadBalancersResponse elbResponse = elb.DescribeLoadBalancers(); WriteFile("elbs.csv", elbResponse.LoadBalancerDescriptions); DescribeInternetGatewaysResponse igResponse = ec2.DescribeInternetGateways(); WriteFile("igs.csv", igResponse.InternetGateways); }