Beispiel #1
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            DescribeInternetGatewaysResponse response = new DescribeInternetGatewaysResponse();

            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("internetGatewaySet/item", targetDepth))
                    {
                        var unmarshaller = InternetGatewayUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.InternetGateways.Add(item);
                        continue;
                    }
                }
            }

            return(response);
        }
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonEC2Config config = new AmazonEC2Config();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonEC2Client client = new AmazonEC2Client(creds, config);

            DescribeInternetGatewaysResponse resp = new DescribeInternetGatewaysResponse();

            do
            {
                DescribeInternetGatewaysRequest req = new DescribeInternetGatewaysRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.DescribeInternetGateways(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.InternetGateways)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
Beispiel #3
0
        public List <DescribeInternetGatewayModel> MapForDescribe(DescribeInternetGatewaysResponse describeInternetGatewaysResponse)
        {
            var model = new List <DescribeInternetGatewayModel>();

            foreach (var internetGateway in describeInternetGatewaysResponse.InternetGateways)
            {
                model.Add(new DescribeInternetGatewayModel()
                {
                    InternetGatewayId = internetGateway.InternetGatewayId
                });
            }

            return(model);
        }
Beispiel #4
0
        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);
        }
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            DescribeInternetGatewaysResponse response = new DescribeInternetGatewaysResponse();

            int targetDepth = 2;

            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("internetGatewaySet/item", targetDepth))
                    {
                        response.InternetGateways.Add(InternetGatewayUnmarshaller.GetInstance().Unmarshall(context));

                        continue;
                    }
                }
            }


            return(response);
        }