public Request<ListClustersRequest> marshall(ListClustersRequest listClustersRequest) {

    if (listClustersRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<ListClustersRequest> request =
        new DefaultRequest<ListClustersRequest>(listClustersRequest, "AmazonElasticMapReduce");
    request.addHeader("X-Amz-Target", "ElasticMapReduce.ListClusters");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (listClustersRequest.getCreatedAfter() != null) {
        jsonGenerator
            .writeFieldName("CreatedAfter")
            .writeValue(listClustersRequest.getCreatedAfter());
      }
      if (listClustersRequest.getCreatedBefore() != null) {
        jsonGenerator
            .writeFieldName("CreatedBefore")
            .writeValue(listClustersRequest.getCreatedBefore());
      }

      com.amazonaws.internal.SdkInternalList<String> clusterStatesList =
          (com.amazonaws.internal.SdkInternalList<String>) listClustersRequest.getClusterStates();
      if (!clusterStatesList.isEmpty() || !clusterStatesList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("ClusterStates");
        jsonGenerator.writeStartArray();
        for (String clusterStatesListValue : clusterStatesList) {
          if (clusterStatesListValue != null) {
            jsonGenerator.writeValue(clusterStatesListValue);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (listClustersRequest.getMarker() != null) {
        jsonGenerator.writeFieldName("Marker").writeValue(listClustersRequest.getMarker());
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", jsonGenerator.getContentType());
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<AddInstanceGroupsRequest> marshall(
      AddInstanceGroupsRequest addInstanceGroupsRequest) {

    if (addInstanceGroupsRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<AddInstanceGroupsRequest> request =
        new DefaultRequest<AddInstanceGroupsRequest>(
            addInstanceGroupsRequest, "AmazonElasticMapReduce");
    request.addHeader("X-Amz-Target", "ElasticMapReduce.AddInstanceGroups");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      com.amazonaws.internal.SdkInternalList<InstanceGroupConfig> instanceGroupsList =
          (com.amazonaws.internal.SdkInternalList<InstanceGroupConfig>)
              addInstanceGroupsRequest.getInstanceGroups();
      if (!instanceGroupsList.isEmpty() || !instanceGroupsList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("InstanceGroups");
        jsonGenerator.writeStartArray();
        for (InstanceGroupConfig instanceGroupsListValue : instanceGroupsList) {
          if (instanceGroupsListValue != null) {

            InstanceGroupConfigJsonMarshaller.getInstance()
                .marshall(instanceGroupsListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (addInstanceGroupsRequest.getJobFlowId() != null) {
        jsonGenerator
            .writeFieldName("JobFlowId")
            .writeValue(addInstanceGroupsRequest.getJobFlowId());
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", jsonGenerator.getContentType());
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }