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);

            DescribeFleetsResponse resp = new DescribeFleetsResponse();

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

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

                foreach (var obj in resp.Fleets)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            DescribeFleetsResponse response = new DescribeFleetsResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Fleets", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Fleet, FleetUnmarshaller>(FleetUnmarshaller.Instance);
                    response.Fleets = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("NextToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextToken = unmarshaller.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)
        {
            DescribeFleetsResponse response = new DescribeFleetsResponse();

            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("fleetSet/item", targetDepth))
                    {
                        var unmarshaller = FleetDataUnmarshaller.Instance;
                        var item         = unmarshaller.Unmarshall(context);
                        response.Fleets.Add(item);
                        continue;
                    }
                    if (context.TestExpression("nextToken", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.NextToken = unmarshaller.Unmarshall(context);
                        continue;
                    }
                }
            }

            return(response);
        }
Example #4
0
        public static DescribeFleetsResponse Unmarshall(UnmarshallerContext context)
        {
            DescribeFleetsResponse describeFleetsResponse = new DescribeFleetsResponse();

            describeFleetsResponse.HttpResponse = context.HttpResponse;
            describeFleetsResponse.RequestId    = context.StringValue("DescribeFleets.RequestId");
            describeFleetsResponse.TotalCount   = context.IntegerValue("DescribeFleets.TotalCount");
            describeFleetsResponse.PageNumber   = context.IntegerValue("DescribeFleets.PageNumber");
            describeFleetsResponse.PageSize     = context.IntegerValue("DescribeFleets.PageSize");

            List <DescribeFleetsResponse.DescribeFleets_Fleet> describeFleetsResponse_fleets = new List <DescribeFleetsResponse.DescribeFleets_Fleet>();

            for (int i = 0; i < context.Length("DescribeFleets.Fleets.Length"); i++)
            {
                DescribeFleetsResponse.DescribeFleets_Fleet fleet = new DescribeFleetsResponse.DescribeFleets_Fleet();
                fleet.FleetId    = context.StringValue("DescribeFleets.Fleets[" + i + "].FleetId");
                fleet.FleetName  = context.StringValue("DescribeFleets.Fleets[" + i + "].FleetName");
                fleet.FleetType  = context.StringValue("DescribeFleets.Fleets[" + i + "].FleetType");
                fleet.Status     = context.StringValue("DescribeFleets.Fleets[" + i + "].Status");
                fleet.State      = context.StringValue("DescribeFleets.Fleets[" + i + "].State");
                fleet.RegionId   = context.StringValue("DescribeFleets.Fleets[" + i + "].RegionId");
                fleet.ValidFrom  = context.StringValue("DescribeFleets.Fleets[" + i + "].ValidFrom");
                fleet.ValidUntil = context.StringValue("DescribeFleets.Fleets[" + i + "].ValidUntil");
                fleet.ExcessCapacityTerminationPolicy = context.StringValue("DescribeFleets.Fleets[" + i + "].ExcessCapacityTerminationPolicy");
                fleet.MaxSpotPrice                     = context.FloatValue("DescribeFleets.Fleets[" + i + "].MaxSpotPrice");
                fleet.LaunchTemplateId                 = context.StringValue("DescribeFleets.Fleets[" + i + "].LaunchTemplateId");
                fleet.LaunchTemplateVersion            = context.StringValue("DescribeFleets.Fleets[" + i + "].LaunchTemplateVersion");
                fleet.TerminateInstances               = context.BooleanValue("DescribeFleets.Fleets[" + i + "].TerminateInstances");
                fleet.TerminateInstancesWithExpiration = context.BooleanValue("DescribeFleets.Fleets[" + i + "].TerminateInstancesWithExpiration");
                fleet.CreationTime                     = context.StringValue("DescribeFleets.Fleets[" + i + "].CreationTime");

                DescribeFleetsResponse.DescribeFleets_Fleet.DescribeFleets_SpotOptions spotOptions = new DescribeFleetsResponse.DescribeFleets_Fleet.DescribeFleets_SpotOptions();
                spotOptions.AllocationStrategy           = context.StringValue("DescribeFleets.Fleets[" + i + "].SpotOptions.AllocationStrategy");
                spotOptions.InstanceInterruptionBehavior = context.StringValue("DescribeFleets.Fleets[" + i + "].SpotOptions.InstanceInterruptionBehavior");
                spotOptions.InstancePoolsToUseCount      = context.IntegerValue("DescribeFleets.Fleets[" + i + "].SpotOptions.InstancePoolsToUseCount");
                fleet.SpotOptions = spotOptions;

                DescribeFleetsResponse.DescribeFleets_Fleet.DescribeFleets_OnDemandOptions onDemandOptions = new DescribeFleetsResponse.DescribeFleets_Fleet.DescribeFleets_OnDemandOptions();
                onDemandOptions.AllocationStrategy = context.StringValue("DescribeFleets.Fleets[" + i + "].OnDemandOptions.AllocationStrategy");
                fleet.OnDemandOptions = onDemandOptions;

                DescribeFleetsResponse.DescribeFleets_Fleet.DescribeFleets_TargetCapacitySpecification targetCapacitySpecification = new DescribeFleetsResponse.DescribeFleets_Fleet.DescribeFleets_TargetCapacitySpecification();
                targetCapacitySpecification.TotalTargetCapacity       = context.FloatValue("DescribeFleets.Fleets[" + i + "].TargetCapacitySpecification.TotalTargetCapacity");
                targetCapacitySpecification.OnDemandTargetCapacity    = context.FloatValue("DescribeFleets.Fleets[" + i + "].TargetCapacitySpecification.OnDemandTargetCapacity");
                targetCapacitySpecification.SpotTargetCapacity        = context.FloatValue("DescribeFleets.Fleets[" + i + "].TargetCapacitySpecification.SpotTargetCapacity");
                targetCapacitySpecification.DefaultTargetCapacityType = context.StringValue("DescribeFleets.Fleets[" + i + "].TargetCapacitySpecification.DefaultTargetCapacityType");
                targetCapacitySpecification.FillGapWithOnDemand       = context.BooleanValue("DescribeFleets.Fleets[" + i + "].TargetCapacitySpecification.FillGapWithOnDemand");
                fleet.TargetCapacitySpecification = targetCapacitySpecification;

                List <DescribeFleetsResponse.DescribeFleets_Fleet.DescribeFleets_LaunchTemplateConfig> fleet_launchTemplateConfigs = new List <DescribeFleetsResponse.DescribeFleets_Fleet.DescribeFleets_LaunchTemplateConfig>();
                for (int j = 0; j < context.Length("DescribeFleets.Fleets[" + i + "].LaunchTemplateConfigs.Length"); j++)
                {
                    DescribeFleetsResponse.DescribeFleets_Fleet.DescribeFleets_LaunchTemplateConfig launchTemplateConfig = new DescribeFleetsResponse.DescribeFleets_Fleet.DescribeFleets_LaunchTemplateConfig();
                    launchTemplateConfig.InstanceType     = context.StringValue("DescribeFleets.Fleets[" + i + "].LaunchTemplateConfigs[" + j + "].InstanceType");
                    launchTemplateConfig.MaxPrice         = context.FloatValue("DescribeFleets.Fleets[" + i + "].LaunchTemplateConfigs[" + j + "].MaxPrice");
                    launchTemplateConfig.VSWitchId        = context.StringValue("DescribeFleets.Fleets[" + i + "].LaunchTemplateConfigs[" + j + "].VSWitchId");
                    launchTemplateConfig.WeightedCapacity = context.FloatValue("DescribeFleets.Fleets[" + i + "].LaunchTemplateConfigs[" + j + "].WeightedCapacity");
                    launchTemplateConfig.Priority         = context.FloatValue("DescribeFleets.Fleets[" + i + "].LaunchTemplateConfigs[" + j + "].Priority");

                    fleet_launchTemplateConfigs.Add(launchTemplateConfig);
                }
                fleet.LaunchTemplateConfigs = fleet_launchTemplateConfigs;

                describeFleetsResponse_fleets.Add(fleet);
            }
            describeFleetsResponse.Fleets = describeFleetsResponse_fleets;

            return(describeFleetsResponse);
        }