public IRequest Marshall(RunJobFlowRequest runJobFlowRequest)
        {
            IRequest request = new DefaultRequest(runJobFlowRequest, "AmazonElasticMapReduce");
            string   target  = "ElasticMapReduce.RunJobFlow";

            request.Headers["X-Amz-Target"] = target;

            request.Headers["Content-Type"] = "application/x-amz-json-1.1";

            string uriResourcePath = "";

            request.ResourcePath = uriResourcePath;


            using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture))
            {
                JsonWriter writer = new JsonWriter(stringWriter);
                writer.WriteObjectStart();

                if (runJobFlowRequest != null && runJobFlowRequest.IsSetName())
                {
                    writer.WritePropertyName("Name");
                    writer.Write(runJobFlowRequest.Name);
                }
                if (runJobFlowRequest != null && runJobFlowRequest.IsSetLogUri())
                {
                    writer.WritePropertyName("LogUri");
                    writer.Write(runJobFlowRequest.LogUri);
                }
                if (runJobFlowRequest != null && runJobFlowRequest.IsSetAdditionalInfo())
                {
                    writer.WritePropertyName("AdditionalInfo");
                    writer.Write(runJobFlowRequest.AdditionalInfo);
                }
                if (runJobFlowRequest != null && runJobFlowRequest.IsSetAmiVersion())
                {
                    writer.WritePropertyName("AmiVersion");
                    writer.Write(runJobFlowRequest.AmiVersion);
                }

                if (runJobFlowRequest != null)
                {
                    JobFlowInstancesConfig instances = runJobFlowRequest.Instances;
                    if (instances != null)
                    {
                        writer.WritePropertyName("Instances");
                        writer.WriteObjectStart();
                        if (instances != null && instances.IsSetMasterInstanceType())
                        {
                            writer.WritePropertyName("MasterInstanceType");
                            writer.Write(instances.MasterInstanceType);
                        }
                        if (instances != null && instances.IsSetSlaveInstanceType())
                        {
                            writer.WritePropertyName("SlaveInstanceType");
                            writer.Write(instances.SlaveInstanceType);
                        }
                        if (instances != null && instances.IsSetInstanceCount())
                        {
                            writer.WritePropertyName("InstanceCount");
                            writer.Write(instances.InstanceCount);
                        }

                        if (instances != null && instances.InstanceGroups != null && instances.InstanceGroups.Count > 0)
                        {
                            List <InstanceGroupConfig> instanceGroupsList = instances.InstanceGroups;
                            writer.WritePropertyName("InstanceGroups");
                            writer.WriteArrayStart();

                            foreach (InstanceGroupConfig instanceGroupsListValue in instanceGroupsList)
                            {
                                writer.WriteObjectStart();
                                if (instanceGroupsListValue != null && instanceGroupsListValue.IsSetName())
                                {
                                    writer.WritePropertyName("Name");
                                    writer.Write(instanceGroupsListValue.Name);
                                }
                                if (instanceGroupsListValue != null && instanceGroupsListValue.IsSetMarket())
                                {
                                    writer.WritePropertyName("Market");
                                    writer.Write(instanceGroupsListValue.Market);
                                }
                                if (instanceGroupsListValue != null && instanceGroupsListValue.IsSetInstanceRole())
                                {
                                    writer.WritePropertyName("InstanceRole");
                                    writer.Write(instanceGroupsListValue.InstanceRole);
                                }
                                if (instanceGroupsListValue != null && instanceGroupsListValue.IsSetBidPrice())
                                {
                                    writer.WritePropertyName("BidPrice");
                                    writer.Write(instanceGroupsListValue.BidPrice);
                                }
                                if (instanceGroupsListValue != null && instanceGroupsListValue.IsSetInstanceType())
                                {
                                    writer.WritePropertyName("InstanceType");
                                    writer.Write(instanceGroupsListValue.InstanceType);
                                }
                                if (instanceGroupsListValue != null && instanceGroupsListValue.IsSetInstanceCount())
                                {
                                    writer.WritePropertyName("InstanceCount");
                                    writer.Write(instanceGroupsListValue.InstanceCount);
                                }
                                writer.WriteObjectEnd();
                            }
                            writer.WriteArrayEnd();
                        }
                        if (instances != null && instances.IsSetEc2KeyName())
                        {
                            writer.WritePropertyName("Ec2KeyName");
                            writer.Write(instances.Ec2KeyName);
                        }

                        if (instances != null)
                        {
                            PlacementType placement = instances.Placement;
                            if (placement != null)
                            {
                                writer.WritePropertyName("Placement");
                                writer.WriteObjectStart();
                                if (placement != null && placement.IsSetAvailabilityZone())
                                {
                                    writer.WritePropertyName("AvailabilityZone");
                                    writer.Write(placement.AvailabilityZone);
                                }
                                writer.WriteObjectEnd();
                            }
                        }
                        if (instances != null && instances.IsSetKeepJobFlowAliveWhenNoSteps())
                        {
                            writer.WritePropertyName("KeepJobFlowAliveWhenNoSteps");
                            writer.Write(instances.KeepJobFlowAliveWhenNoSteps);
                        }
                        if (instances != null && instances.IsSetTerminationProtected())
                        {
                            writer.WritePropertyName("TerminationProtected");
                            writer.Write(instances.TerminationProtected);
                        }
                        if (instances != null && instances.IsSetHadoopVersion())
                        {
                            writer.WritePropertyName("HadoopVersion");
                            writer.Write(instances.HadoopVersion);
                        }
                        if (instances != null && instances.IsSetEc2SubnetId())
                        {
                            writer.WritePropertyName("Ec2SubnetId");
                            writer.Write(instances.Ec2SubnetId);
                        }
                        writer.WriteObjectEnd();
                    }
                }

                if (runJobFlowRequest != null && runJobFlowRequest.Steps != null && runJobFlowRequest.Steps.Count > 0)
                {
                    List <StepConfig> stepsList = runJobFlowRequest.Steps;
                    writer.WritePropertyName("Steps");
                    writer.WriteArrayStart();

                    foreach (StepConfig stepsListValue in stepsList)
                    {
                        writer.WriteObjectStart();
                        if (stepsListValue != null && stepsListValue.IsSetName())
                        {
                            writer.WritePropertyName("Name");
                            writer.Write(stepsListValue.Name);
                        }
                        if (stepsListValue != null && stepsListValue.IsSetActionOnFailure())
                        {
                            writer.WritePropertyName("ActionOnFailure");
                            writer.Write(stepsListValue.ActionOnFailure);
                        }

                        if (stepsListValue != null)
                        {
                            HadoopJarStepConfig hadoopJarStep = stepsListValue.HadoopJarStep;
                            if (hadoopJarStep != null)
                            {
                                writer.WritePropertyName("HadoopJarStep");
                                writer.WriteObjectStart();

                                if (hadoopJarStep != null && hadoopJarStep.Properties != null && hadoopJarStep.Properties.Count > 0)
                                {
                                    List <KeyValue> propertiesList = hadoopJarStep.Properties;
                                    writer.WritePropertyName("Properties");
                                    writer.WriteArrayStart();

                                    foreach (KeyValue propertiesListValue in propertiesList)
                                    {
                                        writer.WriteObjectStart();
                                        if (propertiesListValue != null && propertiesListValue.IsSetKey())
                                        {
                                            writer.WritePropertyName("Key");
                                            writer.Write(propertiesListValue.Key);
                                        }
                                        if (propertiesListValue != null && propertiesListValue.IsSetValue())
                                        {
                                            writer.WritePropertyName("Value");
                                            writer.Write(propertiesListValue.Value);
                                        }
                                        writer.WriteObjectEnd();
                                    }
                                    writer.WriteArrayEnd();
                                }
                                if (hadoopJarStep != null && hadoopJarStep.IsSetJar())
                                {
                                    writer.WritePropertyName("Jar");
                                    writer.Write(hadoopJarStep.Jar);
                                }
                                if (hadoopJarStep != null && hadoopJarStep.IsSetMainClass())
                                {
                                    writer.WritePropertyName("MainClass");
                                    writer.Write(hadoopJarStep.MainClass);
                                }

                                if (hadoopJarStep != null && hadoopJarStep.Args != null && hadoopJarStep.Args.Count > 0)
                                {
                                    List <string> argsList = hadoopJarStep.Args;
                                    writer.WritePropertyName("Args");
                                    writer.WriteArrayStart();

                                    foreach (string argsListValue in argsList)
                                    {
                                        writer.Write(StringUtils.FromString(argsListValue));
                                    }

                                    writer.WriteArrayEnd();
                                }
                                writer.WriteObjectEnd();
                            }
                        }
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }

                if (runJobFlowRequest != null && runJobFlowRequest.BootstrapActions != null && runJobFlowRequest.BootstrapActions.Count > 0)
                {
                    List <BootstrapActionConfig> bootstrapActionsList = runJobFlowRequest.BootstrapActions;
                    writer.WritePropertyName("BootstrapActions");
                    writer.WriteArrayStart();

                    foreach (BootstrapActionConfig bootstrapActionsListValue in bootstrapActionsList)
                    {
                        writer.WriteObjectStart();
                        if (bootstrapActionsListValue != null && bootstrapActionsListValue.IsSetName())
                        {
                            writer.WritePropertyName("Name");
                            writer.Write(bootstrapActionsListValue.Name);
                        }

                        if (bootstrapActionsListValue != null)
                        {
                            ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionsListValue.ScriptBootstrapAction;
                            if (scriptBootstrapAction != null)
                            {
                                writer.WritePropertyName("ScriptBootstrapAction");
                                writer.WriteObjectStart();
                                if (scriptBootstrapAction != null && scriptBootstrapAction.IsSetPath())
                                {
                                    writer.WritePropertyName("Path");
                                    writer.Write(scriptBootstrapAction.Path);
                                }

                                if (scriptBootstrapAction != null && scriptBootstrapAction.Args != null && scriptBootstrapAction.Args.Count > 0)
                                {
                                    List <string> argsList = scriptBootstrapAction.Args;
                                    writer.WritePropertyName("Args");
                                    writer.WriteArrayStart();

                                    foreach (string argsListValue in argsList)
                                    {
                                        writer.Write(StringUtils.FromString(argsListValue));
                                    }

                                    writer.WriteArrayEnd();
                                }
                                writer.WriteObjectEnd();
                            }
                        }
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }

                if (runJobFlowRequest != null && runJobFlowRequest.SupportedProducts != null && runJobFlowRequest.SupportedProducts.Count > 0)
                {
                    List <string> supportedProductsList = runJobFlowRequest.SupportedProducts;
                    writer.WritePropertyName("SupportedProducts");
                    writer.WriteArrayStart();

                    foreach (string supportedProductsListValue in supportedProductsList)
                    {
                        writer.Write(StringUtils.FromString(supportedProductsListValue));
                    }

                    writer.WriteArrayEnd();
                }

                if (runJobFlowRequest != null && runJobFlowRequest.NewSupportedProducts != null && runJobFlowRequest.NewSupportedProducts.Count > 0)
                {
                    List <SupportedProductConfig> newSupportedProductsList = runJobFlowRequest.NewSupportedProducts;
                    writer.WritePropertyName("NewSupportedProducts");
                    writer.WriteArrayStart();

                    foreach (SupportedProductConfig newSupportedProductsListValue in newSupportedProductsList)
                    {
                        writer.WriteObjectStart();
                        if (newSupportedProductsListValue != null && newSupportedProductsListValue.IsSetName())
                        {
                            writer.WritePropertyName("Name");
                            writer.Write(newSupportedProductsListValue.Name);
                        }

                        if (newSupportedProductsListValue != null && newSupportedProductsListValue.Args != null && newSupportedProductsListValue.Args.Count > 0)
                        {
                            List <string> argsList = newSupportedProductsListValue.Args;
                            writer.WritePropertyName("Args");
                            writer.WriteArrayStart();

                            foreach (string argsListValue in argsList)
                            {
                                writer.Write(StringUtils.FromString(argsListValue));
                            }

                            writer.WriteArrayEnd();
                        }
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }
                if (runJobFlowRequest != null && runJobFlowRequest.IsSetVisibleToAllUsers())
                {
                    writer.WritePropertyName("VisibleToAllUsers");
                    writer.Write(runJobFlowRequest.VisibleToAllUsers);
                }
                if (runJobFlowRequest != null && runJobFlowRequest.IsSetJobFlowRole())
                {
                    writer.WritePropertyName("JobFlowRole");
                    writer.Write(runJobFlowRequest.JobFlowRole);
                }

                if (runJobFlowRequest != null && runJobFlowRequest.Tags != null && runJobFlowRequest.Tags.Count > 0)
                {
                    List <Tag> tagsList = runJobFlowRequest.Tags;
                    writer.WritePropertyName("Tags");
                    writer.WriteArrayStart();

                    foreach (Tag tagsListValue in tagsList)
                    {
                        writer.WriteObjectStart();
                        if (tagsListValue != null && tagsListValue.IsSetKey())
                        {
                            writer.WritePropertyName("Key");
                            writer.Write(tagsListValue.Key);
                        }
                        if (tagsListValue != null && tagsListValue.IsSetValue())
                        {
                            writer.WritePropertyName("Value");
                            writer.Write(tagsListValue.Value);
                        }
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }

                writer.WriteObjectEnd();

                string snippet = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(snippet);
            }


            return(request);
        }
        public IRequest Marshall(RunJobFlowRequest runJobFlowRequest)
        {
            IRequest request = new DefaultRequest(runJobFlowRequest, "AmazonElasticMapReduce");

            request.Parameters.Add("Action", "RunJobFlow");
            request.Parameters.Add("Version", "2009-03-31");
            if (runJobFlowRequest != null && runJobFlowRequest.IsSetName())
            {
                request.Parameters.Add("Name", StringUtils.FromString(runJobFlowRequest.Name));
            }
            if (runJobFlowRequest != null && runJobFlowRequest.IsSetLogUri())
            {
                request.Parameters.Add("LogUri", StringUtils.FromString(runJobFlowRequest.LogUri));
            }
            if (runJobFlowRequest != null && runJobFlowRequest.IsSetAdditionalInfo())
            {
                request.Parameters.Add("AdditionalInfo", StringUtils.FromString(runJobFlowRequest.AdditionalInfo));
            }
            if (runJobFlowRequest != null && runJobFlowRequest.IsSetAmiVersion())
            {
                request.Parameters.Add("AmiVersion", StringUtils.FromString(runJobFlowRequest.AmiVersion));
            }
            if (runJobFlowRequest != null)
            {
                JobFlowInstancesConfig instances = runJobFlowRequest.Instances;
                if (instances != null && instances.IsSetMasterInstanceType())
                {
                    request.Parameters.Add("Instances.MasterInstanceType", StringUtils.FromString(instances.MasterInstanceType));
                }
                if (instances != null && instances.IsSetSlaveInstanceType())
                {
                    request.Parameters.Add("Instances.SlaveInstanceType", StringUtils.FromString(instances.SlaveInstanceType));
                }
                if (instances != null && instances.IsSetInstanceCount())
                {
                    request.Parameters.Add("Instances.InstanceCount", StringUtils.FromInt(instances.InstanceCount));
                }

                if (instances != null)
                {
                    List <InstanceGroupConfig> instanceGroupsList = instances.InstanceGroups;
                    int instanceGroupsListIndex = 1;
                    foreach (InstanceGroupConfig instanceGroupsListValue in instanceGroupsList)
                    {
                        if (instanceGroupsListValue != null && instanceGroupsListValue.IsSetName())
                        {
                            request.Parameters.Add("Instances.InstanceGroups.member." + instanceGroupsListIndex + ".Name", StringUtils.FromString(instanceGroupsListValue.Name));
                        }
                        if (instanceGroupsListValue != null && instanceGroupsListValue.IsSetMarket())
                        {
                            request.Parameters.Add("Instances.InstanceGroups.member." + instanceGroupsListIndex + ".Market", StringUtils.FromString(instanceGroupsListValue.Market));
                        }
                        if (instanceGroupsListValue != null && instanceGroupsListValue.IsSetInstanceRole())
                        {
                            request.Parameters.Add("Instances.InstanceGroups.member." + instanceGroupsListIndex + ".InstanceRole", StringUtils.FromString(instanceGroupsListValue.InstanceRole));
                        }
                        if (instanceGroupsListValue != null && instanceGroupsListValue.IsSetBidPrice())
                        {
                            request.Parameters.Add("Instances.InstanceGroups.member." + instanceGroupsListIndex + ".BidPrice", StringUtils.FromString(instanceGroupsListValue.BidPrice));
                        }
                        if (instanceGroupsListValue != null && instanceGroupsListValue.IsSetInstanceType())
                        {
                            request.Parameters.Add("Instances.InstanceGroups.member." + instanceGroupsListIndex + ".InstanceType", StringUtils.FromString(instanceGroupsListValue.InstanceType));
                        }
                        if (instanceGroupsListValue != null && instanceGroupsListValue.IsSetInstanceCount())
                        {
                            request.Parameters.Add("Instances.InstanceGroups.member." + instanceGroupsListIndex + ".InstanceCount", StringUtils.FromInt(instanceGroupsListValue.InstanceCount));
                        }

                        instanceGroupsListIndex++;
                    }
                }
                if (instances != null && instances.IsSetEc2KeyName())
                {
                    request.Parameters.Add("Instances.Ec2KeyName", StringUtils.FromString(instances.Ec2KeyName));
                }
                if (instances != null)
                {
                    PlacementType placement = instances.Placement;
                    if (placement != null && placement.IsSetAvailabilityZone())
                    {
                        request.Parameters.Add("Instances.Placement.AvailabilityZone", StringUtils.FromString(placement.AvailabilityZone));
                    }
                }
                if (instances != null && instances.IsSetKeepJobFlowAliveWhenNoSteps())
                {
                    request.Parameters.Add("Instances.KeepJobFlowAliveWhenNoSteps", StringUtils.FromBool(instances.KeepJobFlowAliveWhenNoSteps));
                }
                if (instances != null && instances.IsSetTerminationProtected())
                {
                    request.Parameters.Add("Instances.TerminationProtected", StringUtils.FromBool(instances.TerminationProtected));
                }
                if (instances != null && instances.IsSetHadoopVersion())
                {
                    request.Parameters.Add("Instances.HadoopVersion", StringUtils.FromString(instances.HadoopVersion));
                }
                if (instances != null && instances.IsSetEc2SubnetId())
                {
                    request.Parameters.Add("Instances.Ec2SubnetId", StringUtils.FromString(instances.Ec2SubnetId));
                }
            }

            if (runJobFlowRequest != null)
            {
                List <StepConfig> stepsList = runJobFlowRequest.Steps;
                int stepsListIndex          = 1;
                foreach (StepConfig stepsListValue in stepsList)
                {
                    if (stepsListValue != null && stepsListValue.IsSetName())
                    {
                        request.Parameters.Add("Steps.member." + stepsListIndex + ".Name", StringUtils.FromString(stepsListValue.Name));
                    }
                    if (stepsListValue != null && stepsListValue.IsSetActionOnFailure())
                    {
                        request.Parameters.Add("Steps.member." + stepsListIndex + ".ActionOnFailure", StringUtils.FromString(stepsListValue.ActionOnFailure));
                    }
                    if (stepsListValue != null)
                    {
                        HadoopJarStepConfig hadoopJarStep = stepsListValue.HadoopJarStep;

                        if (hadoopJarStep != null)
                        {
                            List <KeyValue> propertiesList      = hadoopJarStep.Properties;
                            int             propertiesListIndex = 1;
                            foreach (KeyValue propertiesListValue in propertiesList)
                            {
                                if (propertiesListValue != null && propertiesListValue.IsSetKey())
                                {
                                    request.Parameters.Add("Steps.member." + stepsListIndex + ".HadoopJarStep.Properties.member." + propertiesListIndex + ".Key", StringUtils.FromString(propertiesListValue.Key));
                                }
                                if (propertiesListValue != null && propertiesListValue.IsSetValue())
                                {
                                    request.Parameters.Add("Steps.member." + stepsListIndex + ".HadoopJarStep.Properties.member." + propertiesListIndex + ".Value", StringUtils.FromString(propertiesListValue.Value));
                                }

                                propertiesListIndex++;
                            }
                        }
                        if (hadoopJarStep != null && hadoopJarStep.IsSetJar())
                        {
                            request.Parameters.Add("Steps.member." + stepsListIndex + ".HadoopJarStep.Jar", StringUtils.FromString(hadoopJarStep.Jar));
                        }
                        if (hadoopJarStep != null && hadoopJarStep.IsSetMainClass())
                        {
                            request.Parameters.Add("Steps.member." + stepsListIndex + ".HadoopJarStep.MainClass", StringUtils.FromString(hadoopJarStep.MainClass));
                        }
                        if (hadoopJarStep != null)
                        {
                            List <string> argsList = hadoopJarStep.Args;

                            int argsListIndex = 1;
                            foreach (string argsListValue in argsList)
                            {
                                request.Parameters.Add("Steps.member." + stepsListIndex + ".HadoopJarStep.Args.member." + argsListIndex, StringUtils.FromString(argsListValue));
                                argsListIndex++;
                            }
                        }
                    }

                    stepsListIndex++;
                }
            }

            if (runJobFlowRequest != null)
            {
                List <BootstrapActionConfig> bootstrapActionsList = runJobFlowRequest.BootstrapActions;
                int bootstrapActionsListIndex = 1;
                foreach (BootstrapActionConfig bootstrapActionsListValue in bootstrapActionsList)
                {
                    if (bootstrapActionsListValue != null && bootstrapActionsListValue.IsSetName())
                    {
                        request.Parameters.Add("BootstrapActions.member." + bootstrapActionsListIndex + ".Name", StringUtils.FromString(bootstrapActionsListValue.Name));
                    }
                    if (bootstrapActionsListValue != null)
                    {
                        ScriptBootstrapActionConfig scriptBootstrapAction = bootstrapActionsListValue.ScriptBootstrapAction;
                        if (scriptBootstrapAction != null && scriptBootstrapAction.IsSetPath())
                        {
                            request.Parameters.Add("BootstrapActions.member." + bootstrapActionsListIndex + ".ScriptBootstrapAction.Path", StringUtils.FromString(scriptBootstrapAction.Path));
                        }
                        if (scriptBootstrapAction != null)
                        {
                            List <string> argsList = scriptBootstrapAction.Args;

                            int argsListIndex = 1;
                            foreach (string argsListValue in argsList)
                            {
                                request.Parameters.Add("BootstrapActions.member." + bootstrapActionsListIndex + ".ScriptBootstrapAction.Args.member." + argsListIndex, StringUtils.FromString(argsListValue));
                                argsListIndex++;
                            }
                        }
                    }

                    bootstrapActionsListIndex++;
                }
            }
            if (runJobFlowRequest != null)
            {
                List <string> supportedProductsList = runJobFlowRequest.SupportedProducts;

                int supportedProductsListIndex = 1;
                foreach (string supportedProductsListValue in supportedProductsList)
                {
                    request.Parameters.Add("SupportedProducts.member." + supportedProductsListIndex, StringUtils.FromString(supportedProductsListValue));
                    supportedProductsListIndex++;
                }
            }

            return(request);
        }