public Request<DescribeEcsClustersRequest> marshall(
      DescribeEcsClustersRequest describeEcsClustersRequest) {

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

    Request<DescribeEcsClustersRequest> request =
        new DefaultRequest<DescribeEcsClustersRequest>(describeEcsClustersRequest, "AWSOpsWorks");
    request.addHeader("X-Amz-Target", "OpsWorks_20130218.DescribeEcsClusters");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator =
          SdkJsonProtocolFactory.createWriter(false, "1.1");

      jsonGenerator.writeStartObject();

      com.amazonaws.internal.SdkInternalList<String> ecsClusterArnsList =
          (com.amazonaws.internal.SdkInternalList<String>)
              describeEcsClustersRequest.getEcsClusterArns();
      if (!ecsClusterArnsList.isEmpty() || !ecsClusterArnsList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("EcsClusterArns");
        jsonGenerator.writeStartArray();
        for (String ecsClusterArnsListValue : ecsClusterArnsList) {
          if (ecsClusterArnsListValue != null) {
            jsonGenerator.writeValue(ecsClusterArnsListValue);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (describeEcsClustersRequest.getStackId() != null) {
        jsonGenerator.writeFieldName("StackId").writeValue(describeEcsClustersRequest.getStackId());
      }
      if (describeEcsClustersRequest.getNextToken() != null) {
        jsonGenerator
            .writeFieldName("NextToken")
            .writeValue(describeEcsClustersRequest.getNextToken());
      }
      if (describeEcsClustersRequest.getMaxResults() != null) {
        jsonGenerator
            .writeFieldName("MaxResults")
            .writeValue(describeEcsClustersRequest.getMaxResults());
      }

      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<DetachThingPrincipalRequest> marshall(
      DetachThingPrincipalRequest detachThingPrincipalRequest) {

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

    Request<DetachThingPrincipalRequest> request =
        new DefaultRequest<DetachThingPrincipalRequest>(detachThingPrincipalRequest, "AWSIot");

    request.setHttpMethod(HttpMethodName.DELETE);

    if (detachThingPrincipalRequest.getPrincipal() != null) {
      request.addHeader(
          "x-amzn-principal", StringUtils.fromString(detachThingPrincipalRequest.getPrincipal()));
    }

    String uriResourcePath = "/things/{thingName}/principals";

    uriResourcePath =
        uriResourcePath.replace(
            "{thingName}",
            (detachThingPrincipalRequest.getThingName() == null)
                ? ""
                : StringUtils.fromString(detachThingPrincipalRequest.getThingName()));
    request.setResourcePath(uriResourcePath);

    request.setContent(new ByteArrayInputStream(new byte[0]));
    if (!request.getHeaders().containsKey("Content-Type")) {
      request.addHeader("Content-Type", "binary/octet-stream");
    }

    return request;
  }
  public Request<DetachPrincipalPolicyRequest> marshall(
      DetachPrincipalPolicyRequest detachPrincipalPolicyRequest) {

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

    Request<DetachPrincipalPolicyRequest> request =
        new DefaultRequest<DetachPrincipalPolicyRequest>(detachPrincipalPolicyRequest, "AWSIot");

    request.setHttpMethod(HttpMethodName.DELETE);

    if (detachPrincipalPolicyRequest.getPrincipal() != null) {
      request.addHeader(
          "x-amzn-iot-principal",
          StringUtils.fromString(detachPrincipalPolicyRequest.getPrincipal()));
    }

    String uriResourcePath = "/principal-policies/{policyName}";

    uriResourcePath =
        uriResourcePath.replace(
            "{policyName}",
            (detachPrincipalPolicyRequest.getPolicyName() == null)
                ? ""
                : StringUtils.fromString(detachPrincipalPolicyRequest.getPolicyName()));
    request.setResourcePath(uriResourcePath);

    request.setContent(new ByteArrayInputStream(new byte[0]));
    if (!request.getHeaders().containsKey("Content-Type")) {
      request.addHeader("Content-Type", DEFAULT_CONTENT_TYPE);
    }

    return request;
  }
  public Request<CancelJobRequest> marshall(CancelJobRequest cancelJobRequest) {

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

    Request<CancelJobRequest> request =
        new DefaultRequest<CancelJobRequest>(cancelJobRequest, "AmazonSnowball");
    request.addHeader("X-Amz-Target", "AWSIESnowballJobManagementService.CancelJob");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (cancelJobRequest.getJobId() != null) {
        jsonGenerator.writeFieldName("JobId").writeValue(cancelJobRequest.getJobId());
      }

      jsonGenerator.writeEndObject();

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

    return request;
  }
  public Request<CreateWorkspacesRequest> marshall(
      CreateWorkspacesRequest createWorkspacesRequest) {
    if (createWorkspacesRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<CreateWorkspacesRequest> request =
        new DefaultRequest<CreateWorkspacesRequest>(createWorkspacesRequest, "AmazonWorkspaces");
    String target = "WorkspacesService.CreateWorkspaces";
    request.addHeader("X-Amz-Target", target);

    request.setHttpMethod(HttpMethodName.POST);
    request.setResourcePath("");

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      com.amazonaws.internal.ListWithAutoConstructFlag<WorkspaceRequest> workspacesList =
          (com.amazonaws.internal.ListWithAutoConstructFlag<WorkspaceRequest>)
              (createWorkspacesRequest.getWorkspaces());
      if (workspacesList != null
          && !(workspacesList.isAutoConstruct() && workspacesList.isEmpty())) {

        jsonWriter.key("Workspaces");
        jsonWriter.array();

        for (WorkspaceRequest workspacesListValue : workspacesList) {
          if (workspacesListValue != null) {
            jsonWriter.object();
            if (workspacesListValue.getDirectoryId() != null) {
              jsonWriter.key("DirectoryId").value(workspacesListValue.getDirectoryId());
            }
            if (workspacesListValue.getUserName() != null) {
              jsonWriter.key("UserName").value(workspacesListValue.getUserName());
            }
            if (workspacesListValue.getBundleId() != null) {
              jsonWriter.key("BundleId").value(workspacesListValue.getBundleId());
            }
            jsonWriter.endObject();
          }
        }
        jsonWriter.endArray();
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<DeletePipelineRequest> marshall(DeletePipelineRequest deletePipelineRequest) {

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

    Request<DeletePipelineRequest> request =
        new DefaultRequest<DeletePipelineRequest>(deletePipelineRequest, "AWSCodePipeline");
    request.addHeader("X-Amz-Target", "CodePipeline_20150709.DeletePipeline");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (deletePipelineRequest.getName() != null) {
        jsonGenerator.writeFieldName("name").writeValue(deletePipelineRequest.getName());
      }

      jsonGenerator.writeEndObject();

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

    return request;
  }
  public Request<LookupEventsRequest> marshall(LookupEventsRequest lookupEventsRequest) {

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

    Request<LookupEventsRequest> request =
        new DefaultRequest<LookupEventsRequest>(lookupEventsRequest, "AWSCloudTrail");
    request.addHeader(
        "X-Amz-Target", "com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.LookupEvents");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      com.amazonaws.internal.SdkInternalList<LookupAttribute> lookupAttributesList =
          (com.amazonaws.internal.SdkInternalList<LookupAttribute>)
              lookupEventsRequest.getLookupAttributes();
      if (!lookupAttributesList.isEmpty() || !lookupAttributesList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("LookupAttributes");
        jsonGenerator.writeStartArray();
        for (LookupAttribute lookupAttributesListValue : lookupAttributesList) {
          if (lookupAttributesListValue != null) {

            LookupAttributeJsonMarshaller.getInstance()
                .marshall(lookupAttributesListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (lookupEventsRequest.getStartTime() != null) {
        jsonGenerator.writeFieldName("StartTime").writeValue(lookupEventsRequest.getStartTime());
      }
      if (lookupEventsRequest.getEndTime() != null) {
        jsonGenerator.writeFieldName("EndTime").writeValue(lookupEventsRequest.getEndTime());
      }
      if (lookupEventsRequest.getMaxResults() != null) {
        jsonGenerator.writeFieldName("MaxResults").writeValue(lookupEventsRequest.getMaxResults());
      }
      if (lookupEventsRequest.getNextToken() != null) {
        jsonGenerator.writeFieldName("NextToken").writeValue(lookupEventsRequest.getNextToken());
      }

      jsonGenerator.writeEndObject();

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

    return request;
  }
  public Request<DescribeAccountAttributesRequest> marshall(
      DescribeAccountAttributesRequest describeAccountAttributesRequest) {

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

    Request<DescribeAccountAttributesRequest> request =
        new DefaultRequest<DescribeAccountAttributesRequest>(
            describeAccountAttributesRequest, "AWSOpsWorksCM");
    request.addHeader("X-Amz-Target", "OpsWorksCM_V2016_11_01.DescribeAccountAttributes");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      jsonGenerator.writeEndObject();

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

    return request;
  }
  public Request<ListTablesRequest> marshall(ListTablesRequest listTablesRequest) {
    if (listTablesRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<ListTablesRequest> request =
        new DefaultRequest<ListTablesRequest>(listTablesRequest, "AmazonDynamoDBv2");
    String target = "DynamoDB_20120810.ListTables";
    request.addHeader("X-Amz-Target", target);
    request.addHeader("Content-Type", "application/x-amz-json-1.0");

    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "";

    uriResourcePath = uriResourcePath.replaceAll("//", "/");

    if (uriResourcePath.contains("?")) {
      String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1);
      uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?"));

      for (String s : queryString.split("[;&]")) {
        String[] nameValuePair = s.split("=");
        if (nameValuePair.length == 2) {
          request.addParameter(nameValuePair[0], nameValuePair[1]);
        } else {
          request.addParameter(s, null);
        }
      }
    }

    request.setResourcePath(uriResourcePath);

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (listTablesRequest.getExclusiveStartTableName() != null) {
        jsonWriter
            .key("ExclusiveStartTableName")
            .value(listTablesRequest.getExclusiveStartTableName());
      }
      if (listTablesRequest.getLimit() != null) {
        jsonWriter.key("Limit").value(listTablesRequest.getLimit());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes("UTF-8");
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<TerminateProvisionedProductRequest> marshall(
      TerminateProvisionedProductRequest terminateProvisionedProductRequest) {

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

    Request<TerminateProvisionedProductRequest> request =
        new DefaultRequest<TerminateProvisionedProductRequest>(
            terminateProvisionedProductRequest, "AWSServiceCatalog");
    request.addHeader("X-Amz-Target", "AWS242ServiceCatalogService.TerminateProvisionedProduct");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (terminateProvisionedProductRequest.getProvisionedProductName() != null) {
        jsonGenerator
            .writeFieldName("ProvisionedProductName")
            .writeValue(terminateProvisionedProductRequest.getProvisionedProductName());
      }
      if (terminateProvisionedProductRequest.getProvisionedProductId() != null) {
        jsonGenerator
            .writeFieldName("ProvisionedProductId")
            .writeValue(terminateProvisionedProductRequest.getProvisionedProductId());
      }
      jsonGenerator
          .writeFieldName("TerminateToken")
          .writeValue(
              IdempotentUtils.resolveString(
                  terminateProvisionedProductRequest.getTerminateToken()));
      if (terminateProvisionedProductRequest.getIgnoreErrors() != null) {
        jsonGenerator
            .writeFieldName("IgnoreErrors")
            .writeValue(terminateProvisionedProductRequest.getIgnoreErrors());
      }
      if (terminateProvisionedProductRequest.getAcceptLanguage() != null) {
        jsonGenerator
            .writeFieldName("AcceptLanguage")
            .writeValue(terminateProvisionedProductRequest.getAcceptLanguage());
      }

      jsonGenerator.writeEndObject();

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

    return request;
  }
  public Request<ListOnPremisesInstancesRequest> marshall(
      ListOnPremisesInstancesRequest listOnPremisesInstancesRequest) {

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

    Request<ListOnPremisesInstancesRequest> request =
        new DefaultRequest<ListOnPremisesInstancesRequest>(
            listOnPremisesInstancesRequest, "AmazonCodeDeploy");
    request.addHeader("X-Amz-Target", "CodeDeploy_20141006.ListOnPremisesInstances");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (listOnPremisesInstancesRequest.getRegistrationStatus() != null) {
        jsonGenerator
            .writeFieldName("registrationStatus")
            .writeValue(listOnPremisesInstancesRequest.getRegistrationStatus());
      }

      com.amazonaws.internal.SdkInternalList<TagFilter> tagFiltersList =
          (com.amazonaws.internal.SdkInternalList<TagFilter>)
              listOnPremisesInstancesRequest.getTagFilters();
      if (!tagFiltersList.isEmpty() || !tagFiltersList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("tagFilters");
        jsonGenerator.writeStartArray();
        for (TagFilter tagFiltersListValue : tagFiltersList) {
          if (tagFiltersListValue != null) {

            TagFilterJsonMarshaller.getInstance().marshall(tagFiltersListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (listOnPremisesInstancesRequest.getNextToken() != null) {
        jsonGenerator
            .writeFieldName("nextToken")
            .writeValue(listOnPremisesInstancesRequest.getNextToken());
      }

      jsonGenerator.writeEndObject();

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

    return request;
  }
  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<UpdateDomainNameserversRequest> marshall(
      UpdateDomainNameserversRequest updateDomainNameserversRequest) {

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

    Request<UpdateDomainNameserversRequest> request =
        new DefaultRequest<UpdateDomainNameserversRequest>(
            updateDomainNameserversRequest, "AmazonRoute53Domains");
    request.addHeader("X-Amz-Target", "Route53Domains_v20140515.UpdateDomainNameservers");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (updateDomainNameserversRequest.getDomainName() != null) {
        jsonWriter.key("DomainName").value(updateDomainNameserversRequest.getDomainName());
      }

      if (updateDomainNameserversRequest.getFIAuthKey() != null) {
        jsonWriter.key("FIAuthKey").value(updateDomainNameserversRequest.getFIAuthKey());
      }

      com.amazonaws.internal.SdkInternalList<Nameserver> nameserversList =
          (com.amazonaws.internal.SdkInternalList<Nameserver>)
              updateDomainNameserversRequest.getNameservers();
      if (!nameserversList.isEmpty() || !nameserversList.isAutoConstruct()) {
        jsonWriter.key("Nameservers");
        jsonWriter.array();
        for (Nameserver nameserversListValue : nameserversList) {
          if (nameserversListValue != null) {

            NameserverJsonMarshaller.getInstance().marshall(nameserversListValue, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<ListJobsByStatusRequest> marshall(
      ListJobsByStatusRequest listJobsByStatusRequest) {
    if (listJobsByStatusRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<ListJobsByStatusRequest> request =
        new DefaultRequest<ListJobsByStatusRequest>(
            listJobsByStatusRequest, "AmazonElasticTranscoder");
    String target = "EtsCustomerService.ListJobsByStatus";
    request.addHeader("X-Amz-Target", target);
    request.addHeader("Content-Type", "application/x-amz-json-1.0");

    request.setHttpMethod(HttpMethodName.GET);

    String uriResourcePath =
        "2012-09-25/jobsByStatus/{Status}?Ascending={Ascending};PageToken={PageToken}";
    uriResourcePath =
        uriResourcePath.replace(
            "{Status}",
            (listJobsByStatusRequest.getStatus() == null)
                ? ""
                : StringUtils.fromString(listJobsByStatusRequest.getStatus()));
    uriResourcePath =
        uriResourcePath.replace(
            "{Ascending}",
            (listJobsByStatusRequest.getAscending() == null)
                ? ""
                : StringUtils.fromString(listJobsByStatusRequest.getAscending()));
    uriResourcePath =
        uriResourcePath.replace(
            "{PageToken}",
            (listJobsByStatusRequest.getPageToken() == null)
                ? ""
                : StringUtils.fromString(listJobsByStatusRequest.getPageToken()));

    uriResourcePath = uriResourcePath.replaceAll("//", "/");

    if (uriResourcePath.contains("?")) {
      String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1);
      uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?"));

      for (String s : queryString.split("[;&]")) {
        String[] nameValuePair = s.split("=");
        if (nameValuePair.length == 2) {
          request.addParameter(nameValuePair[0], nameValuePair[1]);
        } else {
          request.addParameter(s, null);
        }
      }
    }

    request.setResourcePath(uriResourcePath);

    request.setContent(new ByteArrayInputStream(new byte[0]));

    return request;
  }
  public Request<CreateSnapshotRequest> marshall(CreateSnapshotRequest createSnapshotRequest) {
    if (createSnapshotRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<CreateSnapshotRequest> request =
        new DefaultRequest<CreateSnapshotRequest>(createSnapshotRequest, "AWSStorageGateway");
    String target = "StorageGateway_20130630.CreateSnapshot";
    request.addHeader("X-Amz-Target", target);
    request.addHeader("Content-Type", "application/x-amz-json-1.1");

    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "";

    uriResourcePath = uriResourcePath.replaceAll("//", "/");

    if (uriResourcePath.contains("?")) {
      String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1);
      uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?"));

      for (String s : queryString.split("[;&]")) {
        String[] nameValuePair = s.split("=");
        if (nameValuePair.length == 2) {
          request.addParameter(nameValuePair[0], nameValuePair[1]);
        } else {
          request.addParameter(s, null);
        }
      }
    }

    request.setResourcePath(uriResourcePath);

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (createSnapshotRequest.getVolumeARN() != null) {
        jsonWriter.key("VolumeARN").value(createSnapshotRequest.getVolumeARN());
      }
      if (createSnapshotRequest.getSnapshotDescription() != null) {
        jsonWriter.key("SnapshotDescription").value(createSnapshotRequest.getSnapshotDescription());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes("UTF-8");
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<CreateConditionalForwarderRequest> marshall(
      CreateConditionalForwarderRequest createConditionalForwarderRequest) {

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

    Request<CreateConditionalForwarderRequest> request =
        new DefaultRequest<CreateConditionalForwarderRequest>(
            createConditionalForwarderRequest, "AWSDirectoryService");
    request.addHeader("X-Amz-Target", "DirectoryService_20150416.CreateConditionalForwarder");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (createConditionalForwarderRequest.getDirectoryId() != null) {
        jsonGenerator
            .writeFieldName("DirectoryId")
            .writeValue(createConditionalForwarderRequest.getDirectoryId());
      }
      if (createConditionalForwarderRequest.getRemoteDomainName() != null) {
        jsonGenerator
            .writeFieldName("RemoteDomainName")
            .writeValue(createConditionalForwarderRequest.getRemoteDomainName());
      }

      com.amazonaws.internal.SdkInternalList<String> dnsIpAddrsList =
          (com.amazonaws.internal.SdkInternalList<String>)
              createConditionalForwarderRequest.getDnsIpAddrs();
      if (!dnsIpAddrsList.isEmpty() || !dnsIpAddrsList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("DnsIpAddrs");
        jsonGenerator.writeStartArray();
        for (String dnsIpAddrsListValue : dnsIpAddrsList) {
          if (dnsIpAddrsListValue != null) {
            jsonGenerator.writeValue(dnsIpAddrsListValue);
          }
        }
        jsonGenerator.writeEndArray();
      }

      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<UpdateByteMatchSetRequest> marshall(
      UpdateByteMatchSetRequest updateByteMatchSetRequest) {

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

    Request<UpdateByteMatchSetRequest> request =
        new DefaultRequest<UpdateByteMatchSetRequest>(updateByteMatchSetRequest, "AWSWAF");
    request.addHeader("X-Amz-Target", "AWSWAF_20150824.UpdateByteMatchSet");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (updateByteMatchSetRequest.getByteMatchSetId() != null) {
        jsonGenerator
            .writeFieldName("ByteMatchSetId")
            .writeValue(updateByteMatchSetRequest.getByteMatchSetId());
      }
      if (updateByteMatchSetRequest.getChangeToken() != null) {
        jsonGenerator
            .writeFieldName("ChangeToken")
            .writeValue(updateByteMatchSetRequest.getChangeToken());
      }

      java.util.List<ByteMatchSetUpdate> updatesList = updateByteMatchSetRequest.getUpdates();
      if (updatesList != null) {
        jsonGenerator.writeFieldName("Updates");
        jsonGenerator.writeStartArray();
        for (ByteMatchSetUpdate updatesListValue : updatesList) {
          if (updatesListValue != null) {

            ByteMatchSetUpdateJsonMarshaller.getInstance()
                .marshall(updatesListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }

      jsonGenerator.writeEndObject();

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

    return request;
  }
  public Request<GetExportRequest> marshall(GetExportRequest getExportRequest) {

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

    Request<GetExportRequest> request =
        new DefaultRequest<GetExportRequest>(getExportRequest, "AmazonApiGateway");

    request.setHttpMethod(HttpMethodName.GET);

    if (getExportRequest.getAccepts() != null) {
      request.addHeader("Accept", StringUtils.fromString(getExportRequest.getAccepts()));
    }

    String uriResourcePath = "/restapis/{restapi_id}/stages/{stage_name}/exports/{export_type}";

    uriResourcePath =
        uriResourcePath.replace(
            "{restapi_id}",
            (getExportRequest.getRestApiId() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(getExportRequest.getRestApiId()), false)
                : "");
    uriResourcePath =
        uriResourcePath.replace(
            "{stage_name}",
            (getExportRequest.getStageName() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(getExportRequest.getStageName()), false)
                : "");
    uriResourcePath =
        uriResourcePath.replace(
            "{export_type}",
            (getExportRequest.getExportType() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(getExportRequest.getExportType()), false)
                : "");
    request.setResourcePath(uriResourcePath);

    java.util.Map<String, String> parameters = getExportRequest.getParameters();
    if (parameters != null) {
      for (Map.Entry<String, String> entry : parameters.entrySet()) {
        if (entry.getValue() != null) {
          request.addParameter(
              StringUtils.fromString(entry.getKey()), StringUtils.fromString(entry.getValue()));
        }
      }
    }

    request.setContent(new ByteArrayInputStream(new byte[0]));
    if (!request.getHeaders().containsKey("Content-Type")) {
      request.addHeader("Content-Type", DEFAULT_CONTENT_TYPE);
    }

    return request;
  }
  public Request<PutEventsRequest> marshall(PutEventsRequest putEventsRequest) {
    if (putEventsRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(PutEventsRequest)");
    }

    Request<PutEventsRequest> request =
        new DefaultRequest<PutEventsRequest>(putEventsRequest, "AmazonMobileAnalytics");
    request.setHttpMethod(HttpMethodName.POST);

    if (putEventsRequest.getClientContext() != null) {
      request.addHeader(
          "x-amz-Client-Context", StringUtils.fromString(putEventsRequest.getClientContext()));
    }
    if (putEventsRequest.getClientContextEncoding() != null) {
      request.addHeader(
          "x-amz-Client-Context-Encoding",
          StringUtils.fromString(putEventsRequest.getClientContextEncoding()));
    }
    String uriResourcePath = "/2014-06-05/events";
    request.setResourcePath(uriResourcePath);
    try {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      GZIPOutputStream gos = new GZIPOutputStream(baos, 8192);
      Writer writer = new OutputStreamWriter(gos, StringUtils.UTF8);
      AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(writer);
      jsonWriter.beginObject();

      if (putEventsRequest.getEvents() != null) {
        java.util.List<Event> events = putEventsRequest.getEvents();
        jsonWriter.name("events");
        jsonWriter.beginArray();
        for (Event eventsItem : events) {
          if (eventsItem != null) {
            EventJsonMarshaller.getInstance().marshall(eventsItem, jsonWriter);
          }
        }
        jsonWriter.endArray();
      }

      jsonWriter.endObject();
      jsonWriter.flush();
      gos.finish();
      writer.close();

      byte[] content = baos.toByteArray();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Encoding", "gzip");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
    if (!request.getHeaders().containsKey("Content-Type")) {
      request.addHeader("Content-Type", "application/x-amz-json-1.0");
    }

    return request;
  }
  public Request<RespondDecisionTaskCompletedRequest> marshall(
      RespondDecisionTaskCompletedRequest respondDecisionTaskCompletedRequest) {

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

    Request<RespondDecisionTaskCompletedRequest> request =
        new DefaultRequest<RespondDecisionTaskCompletedRequest>(
            respondDecisionTaskCompletedRequest, "AmazonSimpleWorkflow");
    request.addHeader("X-Amz-Target", "SimpleWorkflowService.RespondDecisionTaskCompleted");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (respondDecisionTaskCompletedRequest.getTaskToken() != null) {
        jsonGenerator
            .writeFieldName("taskToken")
            .writeValue(respondDecisionTaskCompletedRequest.getTaskToken());
      }

      java.util.List<Decision> decisionsList = respondDecisionTaskCompletedRequest.getDecisions();
      if (decisionsList != null) {
        jsonGenerator.writeFieldName("decisions");
        jsonGenerator.writeStartArray();
        for (Decision decisionsListValue : decisionsList) {
          if (decisionsListValue != null) {

            DecisionJsonMarshaller.getInstance().marshall(decisionsListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (respondDecisionTaskCompletedRequest.getExecutionContext() != null) {
        jsonGenerator
            .writeFieldName("executionContext")
            .writeValue(respondDecisionTaskCompletedRequest.getExecutionContext());
      }

      jsonGenerator.writeEndObject();

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

    return request;
  }
  public Request<CreateHsmRequest> marshall(CreateHsmRequest createHsmRequest) {
    if (createHsmRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<CreateHsmRequest> request =
        new DefaultRequest<CreateHsmRequest>(createHsmRequest, "AWSCloudHSM");
    String target = "CloudHsmFrontendService.CreateHsm";
    request.addHeader("X-Amz-Target", target);

    request.setHttpMethod(HttpMethodName.POST);
    request.setResourcePath("");

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (createHsmRequest.getSubnetId() != null) {
        jsonWriter.key("SubnetId").value(createHsmRequest.getSubnetId());
      }
      if (createHsmRequest.getSshKey() != null) {
        jsonWriter.key("SshKey").value(createHsmRequest.getSshKey());
      }
      if (createHsmRequest.getEniIp() != null) {
        jsonWriter.key("EniIp").value(createHsmRequest.getEniIp());
      }
      if (createHsmRequest.getIamRoleArn() != null) {
        jsonWriter.key("IamRoleArn").value(createHsmRequest.getIamRoleArn());
      }
      if (createHsmRequest.getExternalId() != null) {
        jsonWriter.key("ExternalId").value(createHsmRequest.getExternalId());
      }
      if (createHsmRequest.getSubscriptionType() != null) {
        jsonWriter.key("SubscriptionType").value(createHsmRequest.getSubscriptionType());
      }
      if (createHsmRequest.getClientToken() != null) {
        jsonWriter.key("ClientToken").value(createHsmRequest.getClientToken());
      }
      if (createHsmRequest.getSyslogIp() != null) {
        jsonWriter.key("SyslogIp").value(createHsmRequest.getSyslogIp());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<DeleteTagsRequest> marshall(DeleteTagsRequest deleteTagsRequest) {

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

    Request<DeleteTagsRequest> request =
        new DefaultRequest<DeleteTagsRequest>(deleteTagsRequest, "AWSApplicationDiscovery");
    request.addHeader("X-Amz-Target", "AWSPoseidonService_V2015_11_01.DeleteTags");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      java.util.List<String> configurationIdsList = deleteTagsRequest.getConfigurationIds();
      if (configurationIdsList != null) {
        jsonGenerator.writeFieldName("configurationIds");
        jsonGenerator.writeStartArray();
        for (String configurationIdsListValue : configurationIdsList) {
          if (configurationIdsListValue != null) {
            jsonGenerator.writeValue(configurationIdsListValue);
          }
        }
        jsonGenerator.writeEndArray();
      }

      java.util.List<Tag> tagsList = deleteTagsRequest.getTags();
      if (tagsList != null) {
        jsonGenerator.writeFieldName("tags");
        jsonGenerator.writeStartArray();
        for (Tag tagsListValue : tagsList) {
          if (tagsListValue != null) {

            TagJsonMarshaller.getInstance().marshall(tagsListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }

      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<UpdateMethodRequest> marshall(UpdateMethodRequest updateMethodRequest) {

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

    Request<UpdateMethodRequest> request =
        new DefaultRequest<UpdateMethodRequest>(updateMethodRequest, "AmazonApiGateway");

    request.setHttpMethod(HttpMethodName.PATCH);

    String uriResourcePath = "/restapis/{restapi_id}/resources/{resource_id}/methods/{http_method}";

    uriResourcePath =
        com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall(
            uriResourcePath, "restapi_id", updateMethodRequest.getRestApiId());
    uriResourcePath =
        com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall(
            uriResourcePath, "resource_id", updateMethodRequest.getResourceId());
    uriResourcePath =
        com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall(
            uriResourcePath, "http_method", updateMethodRequest.getHttpMethod());
    request.setResourcePath(uriResourcePath);

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

      java.util.List<PatchOperation> patchOperationsList = updateMethodRequest.getPatchOperations();
      if (patchOperationsList != null) {
        jsonGenerator.writeFieldName("patchOperations");
        jsonGenerator.writeStartArray();
        for (PatchOperation patchOperationsListValue : patchOperationsList) {
          if (patchOperationsListValue != null) {

            PatchOperationJsonMarshaller.getInstance()
                .marshall(patchOperationsListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }

      jsonGenerator.writeEndObject();

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

    return request;
  }
  public Request<CreateIdentityPoolRequest> marshall(
      CreateIdentityPoolRequest createIdentityPoolRequest) {
    if (createIdentityPoolRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<CreateIdentityPoolRequest> request =
        new DefaultRequest<CreateIdentityPoolRequest>(
            createIdentityPoolRequest, "AmazonCognitoIdentity");
    String target = "AWSCognitoIdentityService.CreateIdentityPool";
    request.addHeader("X-Amz-Target", target);

    request.setHttpMethod(HttpMethodName.POST);
    request.setResourcePath("");

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (createIdentityPoolRequest.getIdentityPoolName() != null) {
        jsonWriter.key("IdentityPoolName").value(createIdentityPoolRequest.getIdentityPoolName());
      }
      if (createIdentityPoolRequest.isAllowUnauthenticatedIdentities() != null) {
        jsonWriter
            .key("AllowUnauthenticatedIdentities")
            .value(createIdentityPoolRequest.isAllowUnauthenticatedIdentities());
      }
      if (createIdentityPoolRequest.getSupportedLoginProviders() != null) {
        jsonWriter.key("SupportedLoginProviders");
        jsonWriter.object();
        for (Map.Entry<String, String> supportedLoginProvidersListValue :
            createIdentityPoolRequest.getSupportedLoginProviders().entrySet()) {
          if (supportedLoginProvidersListValue.getValue() != null) {
            jsonWriter.key(supportedLoginProvidersListValue.getKey());

            jsonWriter.value(supportedLoginProvidersListValue.getValue());
          }
        }
        jsonWriter.endObject();
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", "application/x-amz-json-1.0");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<DescribeRaidArraysRequest> marshall(
      DescribeRaidArraysRequest describeRaidArraysRequest) {

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

    Request<DescribeRaidArraysRequest> request =
        new DefaultRequest<DescribeRaidArraysRequest>(describeRaidArraysRequest, "AWSOpsWorks");
    request.addHeader("X-Amz-Target", "OpsWorks_20130218.DescribeRaidArrays");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (describeRaidArraysRequest.getInstanceId() != null) {
        jsonGenerator
            .writeFieldName("InstanceId")
            .writeValue(describeRaidArraysRequest.getInstanceId());
      }
      if (describeRaidArraysRequest.getStackId() != null) {
        jsonGenerator.writeFieldName("StackId").writeValue(describeRaidArraysRequest.getStackId());
      }

      com.amazonaws.internal.SdkInternalList<String> raidArrayIdsList =
          (com.amazonaws.internal.SdkInternalList<String>)
              describeRaidArraysRequest.getRaidArrayIds();
      if (!raidArrayIdsList.isEmpty() || !raidArrayIdsList.isAutoConstruct()) {
        jsonGenerator.writeFieldName("RaidArrayIds");
        jsonGenerator.writeStartArray();
        for (String raidArrayIdsListValue : raidArrayIdsList) {
          if (raidArrayIdsListValue != null) {
            jsonGenerator.writeValue(raidArrayIdsListValue);
          }
        }
        jsonGenerator.writeEndArray();
      }

      jsonGenerator.writeEndObject();

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

    return request;
  }
  public Request<MergeDeveloperIdentitiesRequest> marshall(
      MergeDeveloperIdentitiesRequest mergeDeveloperIdentitiesRequest) {

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

    Request<MergeDeveloperIdentitiesRequest> request =
        new DefaultRequest<MergeDeveloperIdentitiesRequest>(
            mergeDeveloperIdentitiesRequest, "AmazonCognitoIdentity");
    request.addHeader("X-Amz-Target", "AWSCognitoIdentityService.MergeDeveloperIdentities");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (mergeDeveloperIdentitiesRequest.getSourceUserIdentifier() != null) {
        jsonGenerator
            .writeFieldName("SourceUserIdentifier")
            .writeValue(mergeDeveloperIdentitiesRequest.getSourceUserIdentifier());
      }
      if (mergeDeveloperIdentitiesRequest.getDestinationUserIdentifier() != null) {
        jsonGenerator
            .writeFieldName("DestinationUserIdentifier")
            .writeValue(mergeDeveloperIdentitiesRequest.getDestinationUserIdentifier());
      }
      if (mergeDeveloperIdentitiesRequest.getDeveloperProviderName() != null) {
        jsonGenerator
            .writeFieldName("DeveloperProviderName")
            .writeValue(mergeDeveloperIdentitiesRequest.getDeveloperProviderName());
      }
      if (mergeDeveloperIdentitiesRequest.getIdentityPoolId() != null) {
        jsonGenerator
            .writeFieldName("IdentityPoolId")
            .writeValue(mergeDeveloperIdentitiesRequest.getIdentityPoolId());
      }

      jsonGenerator.writeEndObject();

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

    return request;
  }
  public Request<SetIdentityPoolRolesRequest> marshall(
      SetIdentityPoolRolesRequest setIdentityPoolRolesRequest) {

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

    Request<SetIdentityPoolRolesRequest> request =
        new DefaultRequest<SetIdentityPoolRolesRequest>(
            setIdentityPoolRolesRequest, "AmazonCognitoIdentity");
    request.addHeader("X-Amz-Target", "AWSCognitoIdentityService.SetIdentityPoolRoles");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (setIdentityPoolRolesRequest.getIdentityPoolId() != null) {
        jsonWriter.key("IdentityPoolId").value(setIdentityPoolRolesRequest.getIdentityPoolId());
      }

      java.util.Map<String, String> rolesMap = setIdentityPoolRolesRequest.getRoles();
      if (rolesMap != null) {
        jsonWriter.key("Roles");
        jsonWriter.object();

        for (Map.Entry<String, String> rolesMapValue : rolesMap.entrySet()) {
          if (rolesMapValue.getValue() != null) {
            jsonWriter.key(rolesMapValue.getKey());

            jsonWriter.value(rolesMapValue.getValue());
          }
        }
        jsonWriter.endObject();
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    } 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;
  }
  public Request<SetLoadBasedAutoScalingRequest> marshall(
      SetLoadBasedAutoScalingRequest setLoadBasedAutoScalingRequest) {

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

    Request<SetLoadBasedAutoScalingRequest> request =
        new DefaultRequest<SetLoadBasedAutoScalingRequest>(
            setLoadBasedAutoScalingRequest, "AWSOpsWorks");
    request.addHeader("X-Amz-Target", "OpsWorks_20130218.SetLoadBasedAutoScaling");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

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

      jsonGenerator.writeStartObject();

      if (setLoadBasedAutoScalingRequest.getLayerId() != null) {
        jsonGenerator
            .writeFieldName("LayerId")
            .writeValue(setLoadBasedAutoScalingRequest.getLayerId());
      }
      if (setLoadBasedAutoScalingRequest.getEnable() != null) {
        jsonGenerator
            .writeFieldName("Enable")
            .writeValue(setLoadBasedAutoScalingRequest.getEnable());
      }
      if (setLoadBasedAutoScalingRequest.getUpScaling() != null) {
        jsonGenerator.writeFieldName("UpScaling");
        AutoScalingThresholdsJsonMarshaller.getInstance()
            .marshall(setLoadBasedAutoScalingRequest.getUpScaling(), jsonGenerator);
      }
      if (setLoadBasedAutoScalingRequest.getDownScaling() != null) {
        jsonGenerator.writeFieldName("DownScaling");
        AutoScalingThresholdsJsonMarshaller.getInstance()
            .marshall(setLoadBasedAutoScalingRequest.getDownScaling(), jsonGenerator);
      }

      jsonGenerator.writeEndObject();

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

    return request;
  }
  public Request<UpdateHostedZoneCommentRequest> marshall(
      UpdateHostedZoneCommentRequest updateHostedZoneCommentRequest) {

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

    Request<UpdateHostedZoneCommentRequest> request =
        new DefaultRequest<UpdateHostedZoneCommentRequest>(
            updateHostedZoneCommentRequest, "AmazonRoute53");

    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "/2013-04-01/hostedzone/{Id}";

    uriResourcePath =
        uriResourcePath.replace(
            "{Id}",
            (updateHostedZoneCommentRequest.getId() != null)
                ? SdkHttpUtils.urlEncode(
                    StringUtils.fromString(updateHostedZoneCommentRequest.getId()), false)
                : "");
    request.setResourcePath(uriResourcePath);

    try {
      StringWriter stringWriter = new StringWriter();
      XMLWriter xmlWriter =
          new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/");

      xmlWriter.startElement("UpdateHostedZoneCommentRequest");
      if (updateHostedZoneCommentRequest != null) {

        if (updateHostedZoneCommentRequest.getComment() != null) {
          xmlWriter
              .startElement("Comment")
              .value(updateHostedZoneCommentRequest.getComment())
              .endElement();
        }
      }
      xmlWriter.endElement();

      request.setContent(new StringInputStream(stringWriter.getBuffer().toString()));
      request.addHeader(
          "Content-Length",
          Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length));
      if (!request.getHeaders().containsKey("Content-Type")) {
        request.addHeader("Content-Type", "application/xml");
      }
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to XML: " + t.getMessage(), t);
    }

    return request;
  }